| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ |
| 6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "services/media/framework/types/stream_type.h" | 8 #include "services/media/framework/types/stream_type.h" |
| 9 #include "services/media/framework/types/video_stream_type.h" | 9 #include "services/media/framework/types/video_stream_type.h" |
| 10 extern "C" { | 10 extern "C" { |
| 11 #include "third_party/ffmpeg/libavformat/avformat.h" | 11 #include "third_party/ffmpeg/libavformat/avformat.h" |
| 12 } | 12 } |
| 13 | 13 |
| 14 // Ffmeg defines this...undefine. |
| 15 #undef PixelFormat |
| 16 |
| 14 namespace mojo { | 17 namespace mojo { |
| 15 namespace media { | 18 namespace media { |
| 16 | 19 |
| 17 struct AVCodecContextDeleter { | 20 struct AVCodecContextDeleter { |
| 18 void operator()(AVCodecContext* context) const { | 21 void operator()(AVCodecContext* context) const { |
| 19 avcodec_free_context(&context); | 22 avcodec_free_context(&context); |
| 20 } | 23 } |
| 21 }; | 24 }; |
| 22 | 25 |
| 23 using AvCodecContextPtr = | 26 using AvCodecContextPtr = |
| 24 std::unique_ptr<AVCodecContext, AVCodecContextDeleter>; | 27 std::unique_ptr<AVCodecContext, AVCodecContextDeleter>; |
| 25 | 28 |
| 26 struct AvCodecContext { | 29 struct AvCodecContext { |
| 27 static AvCodecContextPtr Create(const StreamType& stream_type); | 30 static AvCodecContextPtr Create(const StreamType& stream_type); |
| 28 | 31 |
| 29 static std::unique_ptr<StreamType> GetStreamType(const AVCodecContext& from); | 32 static std::unique_ptr<StreamType> GetStreamType(const AVCodecContext& from); |
| 30 }; | 33 }; |
| 31 | 34 |
| 35 // Converts an AVPixelFormat to a PixelFormat. |
| 36 VideoStreamType::PixelFormat PixelFormatFromAVPixelFormat( |
| 37 AVPixelFormat av_pixel_format); |
| 38 |
| 39 // Converts a PixelFormat to an AVPixelFormat. |
| 40 AVPixelFormat AVPixelFormatFromPixelFormat( |
| 41 VideoStreamType::PixelFormat pixel_format); |
| 42 |
| 32 } // namespace media | 43 } // namespace media |
| 33 } // namespace mojo | 44 } // namespace mojo |
| 34 | 45 |
| 35 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ | 46 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_CODEC_CONTEXT_H_ |
| OLD | NEW |