| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. Use of this | |
| 2 // source code is governed by a BSD-style license that can be found in the | |
| 3 // LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_OMX_OMX_CONFIGURATOR_H_ | |
| 6 #define MEDIA_OMX_OMX_CONFIGURATOR_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "third_party/openmax/il/OMX_Component.h" | |
| 12 #include "third_party/openmax/il/OMX_Core.h" | |
| 13 #include "third_party/openmax/il/OMX_Video.h" | |
| 14 | |
| 15 namespace media { | |
| 16 | |
| 17 class OmxConfigurator { | |
| 18 public: | |
| 19 enum Codec { | |
| 20 kCodecNone, | |
| 21 kCodecH264, | |
| 22 kCodecMpeg4, | |
| 23 kCodecH263, | |
| 24 kCodecVc1, | |
| 25 kCodecRaw, | |
| 26 }; | |
| 27 | |
| 28 // TODO(jiesun): figure out what other surface formats are. | |
| 29 enum SurfaceFormat { | |
| 30 kSurfaceFormatNV21, | |
| 31 kSurfaceFormatNV21Tiled, | |
| 32 kSurfaceFormatNV12, | |
| 33 }; | |
| 34 | |
| 35 struct MediaFormatVideoHeader { | |
| 36 int width; | |
| 37 int height; | |
| 38 int stride; // n/a to compressed stream. | |
| 39 int frame_rate; | |
| 40 int bit_rate; // n/a to raw stream. | |
| 41 int profile; // n/a to raw stream. | |
| 42 int level; // n/a to raw stream. | |
| 43 int i_dist; // i frame distance; >0 if p frame is enabled. | |
| 44 int p_dist; // p frame distance; >0 if b frame is enabled. | |
| 45 }; | |
| 46 | |
| 47 struct MediaFormatVideoRaw { | |
| 48 SurfaceFormat color_space; | |
| 49 }; | |
| 50 | |
| 51 struct MediaFormatVideoH264 { | |
| 52 int slice_enable; | |
| 53 int max_ref_frames; | |
| 54 int num_ref_l0, num_ref_l1; | |
| 55 int cabac_enable; | |
| 56 int cabac_init_idc; | |
| 57 int deblock_enable; | |
| 58 int frame_mbs_only_flags; | |
| 59 int mbaff_enable; | |
| 60 int bdirect_spatial_temporal; | |
| 61 }; | |
| 62 | |
| 63 struct MediaFormatVideoMPEG4 { | |
| 64 int ac_pred_enable; | |
| 65 int time_inc_res; | |
| 66 int slice_enable; | |
| 67 }; | |
| 68 | |
| 69 struct MediaFormat { | |
| 70 // TODO(jiesun): instead of codec type, we should have media format. | |
| 71 Codec codec; | |
| 72 MediaFormatVideoHeader video_header; | |
| 73 union { | |
| 74 MediaFormatVideoRaw raw; | |
| 75 MediaFormatVideoH264 h264; | |
| 76 MediaFormatVideoMPEG4 mpeg4; | |
| 77 }; | |
| 78 }; | |
| 79 | |
| 80 OmxConfigurator(const MediaFormat& input, | |
| 81 const MediaFormat& output) | |
| 82 : input_format_(input), | |
| 83 output_format_(output) { | |
| 84 } | |
| 85 | |
| 86 virtual ~OmxConfigurator() {} | |
| 87 | |
| 88 // Returns the role name for this configuration. | |
| 89 virtual std::string GetRoleName() const = 0; | |
| 90 | |
| 91 // Called by OmxCodec on the message loop given to it during | |
| 92 // transition to idle state. | |
| 93 // OmxCodec reads the current IO port definitions and pass it to this | |
| 94 // method. | |
| 95 // Returns true if configuration has completed successfully. | |
| 96 virtual bool ConfigureIOPorts( | |
| 97 OMX_COMPONENTTYPE* component, | |
| 98 OMX_PARAM_PORTDEFINITIONTYPE* input_port_def, | |
| 99 OMX_PARAM_PORTDEFINITIONTYPE* output_port_def) const = 0; | |
| 100 | |
| 101 const MediaFormat& input_format() const { return input_format_; } | |
| 102 const MediaFormat& output_format() const { return output_format_; } | |
| 103 | |
| 104 private: | |
| 105 MediaFormat input_format_; | |
| 106 MediaFormat output_format_; | |
| 107 | |
| 108 private: | |
| 109 DISALLOW_COPY_AND_ASSIGN(OmxConfigurator); | |
| 110 }; | |
| 111 | |
| 112 class OmxDecoderConfigurator : public OmxConfigurator { | |
| 113 public: | |
| 114 OmxDecoderConfigurator(const MediaFormat& input, | |
| 115 const MediaFormat& output) | |
| 116 : OmxConfigurator(input, output) { | |
| 117 } | |
| 118 | |
| 119 virtual ~OmxDecoderConfigurator() {} | |
| 120 | |
| 121 virtual std::string GetRoleName() const; | |
| 122 | |
| 123 virtual bool ConfigureIOPorts( | |
| 124 OMX_COMPONENTTYPE* component, | |
| 125 OMX_PARAM_PORTDEFINITIONTYPE* input_port_def, | |
| 126 OMX_PARAM_PORTDEFINITIONTYPE* output_port_def) const; | |
| 127 | |
| 128 private: | |
| 129 DISALLOW_COPY_AND_ASSIGN(OmxDecoderConfigurator); | |
| 130 }; | |
| 131 | |
| 132 class OmxEncoderConfigurator : public OmxConfigurator { | |
| 133 public: | |
| 134 OmxEncoderConfigurator(const MediaFormat& input, | |
| 135 const MediaFormat& output) | |
| 136 : OmxConfigurator(input, output) { | |
| 137 } | |
| 138 | |
| 139 virtual ~OmxEncoderConfigurator() {} | |
| 140 | |
| 141 virtual std::string GetRoleName() const; | |
| 142 | |
| 143 virtual bool ConfigureIOPorts( | |
| 144 OMX_COMPONENTTYPE* component, | |
| 145 OMX_PARAM_PORTDEFINITIONTYPE* input_port_def, | |
| 146 OMX_PARAM_PORTDEFINITIONTYPE* output_port_def) const; | |
| 147 | |
| 148 private: | |
| 149 DISALLOW_COPY_AND_ASSIGN(OmxEncoderConfigurator); | |
| 150 }; | |
| 151 | |
| 152 } // namespace media | |
| 153 | |
| 154 #endif // MEDIA_OMX_OMX_CONFIGURATOR_H_ | |
| OLD | NEW |