• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //#define LOG_NDEBUG 0
18 #define LOG_TAG "MPEG2ExtractorBundle"
19 #include <utils/Log.h>
20 
21 #include <media/MediaExtractorPluginHelper.h>
22 #include <media/stagefright/MediaDefs.h>
23 #include "MPEG2PSExtractor.h"
24 #include "MPEG2TSExtractor.h"
25 
26 namespace android {
27 
28 struct CDataSource;
29 
30 static const char *extensions[] = {
31    "m2p",
32    "m2ts",
33    "mts",
34    "ts",
35    NULL
36 };
37 
38 extern "C" {
39 // This is the only symbol that needs to be exported
40 __attribute__ ((visibility ("default")))
GETEXTRACTORDEF()41 ExtractorDef GETEXTRACTORDEF() {
42     return {
43         EXTRACTORDEF_VERSION,
44         UUID("3d1dcfeb-e40a-436d-a574-c2438a555e5f"),
45         1,
46         "MPEG2-PS/TS Extractor",
47         {
48             .v3 = {
49                 [](
50                     CDataSource *source,
51                     float *confidence,
52                     void **,
53                     FreeMetaFunc *) -> CreatorFunc {
54                     DataSourceHelper helper(source);
55                     if (SniffMPEG2TS(&helper, confidence)) {
56                         return [](
57                                 CDataSource *source,
58                                 void *) -> CMediaExtractor* {
59                             return wrap(new MPEG2TSExtractor(new DataSourceHelper(source)));};
60                     } else if (SniffMPEG2PS(&helper, confidence)) {
61                         return [](
62                                 CDataSource *source,
63                                 void *) -> CMediaExtractor* {
64                             return wrap(new MPEG2PSExtractor(new DataSourceHelper(source)));};
65                     }
66                     return NULL;
67                 },
68                 extensions
69             }
70         },
71     };
72 }
73 
74 } // extern "C"
75 
76 } // namespace android
77