Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
|
Ami GONE FROM CHROMIUM
2012/07/11 22:33:17
rietveld is showing this as a modification, not a
xhwang
2012/07/12 00:21:45
I don't know why it's shown as modified :\, it's n
| |
| 4 | |
| 5 // Interface and some concrete classes for applying various transforms | |
| 6 // to AVPackets. FFmpegBitstreamConverter, in particular, can be used | |
| 7 // to apply FFmpeg bitstream filters to the incoming AVPacket to transcode | |
| 8 // the packet format. | |
| 9 | |
| 10 #ifndef MEDIA_FILTERS_BITSTREAM_CONVERTER_H_ | |
| 11 #define MEDIA_FILTERS_BITSTREAM_CONVERTER_H_ | |
| 12 | |
| 13 #include <string> | |
| 14 | |
| 15 #include "base/basictypes.h" | |
| 16 #include "base/compiler_specific.h" | |
| 17 #include "base/gtest_prod_util.h" | |
| 18 #include "media/base/media_export.h" | |
| 19 | |
| 20 // FFmpeg types. | |
| 21 struct AVBitStreamFilterContext; | |
| 22 struct AVCodecContext; | |
| 23 struct AVPacket; | |
| 24 | |
| 25 namespace media { | |
| 26 | |
| 27 class MEDIA_EXPORT BitstreamConverter { | |
| 28 public: | |
| 29 BitstreamConverter() {} | |
| 30 virtual ~BitstreamConverter() {} | |
| 31 | |
| 32 // Initialize does any preparations needed before doing the actual | |
| 33 // conversion. | |
| 34 virtual bool Initialize() = 0; | |
| 35 | |
| 36 // Attemps to convert the AVPacket from one format to another, based on the | |
| 37 // specific type of BitstreamConverter that was instantiated. Output will be | |
| 38 // stored into the |packet|, but user should be aware that conversion can free | |
| 39 // and reallocate the input buffer, if it needs to do so to fit it in. | |
| 40 virtual bool ConvertPacket(AVPacket* packet) = 0; | |
| 41 | |
| 42 private: | |
| 43 DISALLOW_COPY_AND_ASSIGN(BitstreamConverter); | |
| 44 }; | |
| 45 | |
| 46 class IdentityBitstreamConverter : public BitstreamConverter { | |
| 47 public: | |
| 48 IdentityBitstreamConverter() {} | |
| 49 virtual ~IdentityBitstreamConverter() {} | |
| 50 | |
| 51 virtual bool Initialize() OVERRIDE; | |
| 52 virtual bool ConvertPacket(AVPacket* packet) OVERRIDE; | |
| 53 | |
| 54 private: | |
| 55 DISALLOW_COPY_AND_ASSIGN(IdentityBitstreamConverter); | |
| 56 }; | |
| 57 | |
| 58 class MEDIA_EXPORT FFmpegBitstreamConverter : public BitstreamConverter { | |
| 59 public: | |
| 60 // Creates FFmpegBitstreamConverter based on the FFmpeg bistream filter | |
| 61 // corresponding to |filter_name|. | |
| 62 // | |
| 63 // The |stream_context| will be used during conversion and should be the | |
| 64 // AVCodecContext for the stream sourcing these packets. A reference to | |
| 65 // |stream_context| is retained, so it must outlive this class. | |
| 66 FFmpegBitstreamConverter(const std::string& filter_name, | |
| 67 AVCodecContext* stream_context); | |
| 68 virtual ~FFmpegBitstreamConverter(); | |
| 69 | |
| 70 virtual bool Initialize() OVERRIDE; | |
| 71 virtual bool ConvertPacket(AVPacket* packet) OVERRIDE; | |
| 72 | |
| 73 private: | |
| 74 std::string filter_name_; | |
| 75 AVBitStreamFilterContext* stream_filter_; | |
| 76 AVCodecContext* stream_context_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(FFmpegBitstreamConverter); | |
| 79 }; | |
| 80 | |
| 81 } // namespace media | |
| 82 | |
| 83 #endif // MEDIA_FILTERS_BITSTREAM_CONVERTER_H_ | |
| OLD | NEW |