| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 5 #ifndef MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| 6 #define MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 6 #define MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 // Used for FFmpeg error codes. | 10 // Used for FFmpeg error codes. |
| 11 #include <cerrno> | 11 #include <cerrno> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_codecs.h" |
| 16 #include "media/base/channel_layout.h" | 16 #include "media/base/channel_layout.h" |
| 17 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
| 18 #include "media/base/sample_format.h" |
| 18 #include "media/base/video_codecs.h" | 19 #include "media/base/video_codecs.h" |
| 19 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
| 20 #include "media/ffmpeg/ffmpeg_deleters.h" | 21 #include "media/ffmpeg/ffmpeg_deleters.h" |
| 21 | 22 |
| 22 // Include FFmpeg header files. | 23 // Include FFmpeg header files. |
| 23 extern "C" { | 24 extern "C" { |
| 24 // Disable deprecated features which result in spammy compile warnings. This | 25 // Disable deprecated features which result in spammy compile warnings. This |
| 25 // list of defines must mirror those in the 'defines' section of BUILD.gn file & | 26 // list of defines must mirror those in the 'defines' section of BUILD.gn file & |
| 26 // ffmpeg.gyp file or the headers below will generate different structures! | 27 // ffmpeg.gyp file or the headers below will generate different structures! |
| 27 #define FF_API_CONVERGENCE_DURATION 0 | 28 #define FF_API_CONVERGENCE_DURATION 0 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 const AVCodecContext* codec_context, | 115 const AVCodecContext* codec_context, |
| 115 bool is_encrypted, | 116 bool is_encrypted, |
| 116 AudioDecoderConfig* config); | 117 AudioDecoderConfig* config); |
| 117 | 118 |
| 118 // Converts FFmpeg's channel layout to chrome's ChannelLayout. |channels| can | 119 // Converts FFmpeg's channel layout to chrome's ChannelLayout. |channels| can |
| 119 // be used when FFmpeg's channel layout is not informative in order to make a | 120 // be used when FFmpeg's channel layout is not informative in order to make a |
| 120 // good guess about the plausible channel layout based on number of channels. | 121 // good guess about the plausible channel layout based on number of channels. |
| 121 MEDIA_EXPORT ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, | 122 MEDIA_EXPORT ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, |
| 122 int channels); | 123 int channels); |
| 123 | 124 |
| 125 MEDIA_EXPORT AVCodecID AudioCodecToCodecID(AudioCodec audio_codec, |
| 126 SampleFormat sample_format); |
| 124 MEDIA_EXPORT AVCodecID VideoCodecToCodecID(VideoCodec video_codec); | 127 MEDIA_EXPORT AVCodecID VideoCodecToCodecID(VideoCodec video_codec); |
| 125 | 128 |
| 126 // Converts FFmpeg's audio sample format to Chrome's SampleFormat. | 129 // Converts FFmpeg's audio sample format to Chrome's SampleFormat. |
| 127 MEDIA_EXPORT SampleFormat | 130 MEDIA_EXPORT SampleFormat |
| 128 AVSampleFormatToSampleFormat(AVSampleFormat sample_format, AVCodecID codec_id); | 131 AVSampleFormatToSampleFormat(AVSampleFormat sample_format, AVCodecID codec_id); |
| 129 | 132 |
| 130 // Converts FFmpeg's pixel formats to its corresponding supported video format. | 133 // Converts FFmpeg's pixel formats to its corresponding supported video format. |
| 131 MEDIA_EXPORT VideoPixelFormat | 134 MEDIA_EXPORT VideoPixelFormat |
| 132 AVPixelFormatToVideoPixelFormat(AVPixelFormat pixel_format); | 135 AVPixelFormatToVideoPixelFormat(AVPixelFormat pixel_format); |
| 133 | 136 |
| 134 // Converts video formats to its corresponding FFmpeg's pixel formats. | 137 // Converts video formats to its corresponding FFmpeg's pixel formats. |
| 135 AVPixelFormat VideoPixelFormatToAVPixelFormat(VideoPixelFormat video_format); | 138 AVPixelFormat VideoPixelFormatToAVPixelFormat(VideoPixelFormat video_format); |
| 136 | 139 |
| 137 ColorSpace AVColorSpaceToColorSpace(AVColorSpace color_space, | 140 ColorSpace AVColorSpaceToColorSpace(AVColorSpace color_space, |
| 138 AVColorRange color_range); | 141 AVColorRange color_range); |
| 139 | 142 |
| 140 // Convert FFmpeg UTC representation (YYYY-MM-DD HH:MM:SS) to base::Time. | 143 // Convert FFmpeg UTC representation (YYYY-MM-DD HH:MM:SS) to base::Time. |
| 141 // Returns true and sets |*out| if |date_utc| contains a valid | 144 // Returns true and sets |*out| if |date_utc| contains a valid |
| 142 // date string. Otherwise returns fals and timeline_offset is unmodified. | 145 // date string. Otherwise returns fals and timeline_offset is unmodified. |
| 143 MEDIA_EXPORT bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out); | 146 MEDIA_EXPORT bool FFmpegUTCDateToTime(const char* date_utc, base::Time* out); |
| 144 | 147 |
| 145 // Returns a 32-bit hash for the given codec name. See the VerifyUmaCodecHashes | 148 // Returns a 32-bit hash for the given codec name. See the VerifyUmaCodecHashes |
| 146 // unit test for more information and code for generating the histogram XML. | 149 // unit test for more information and code for generating the histogram XML. |
| 147 MEDIA_EXPORT int32_t HashCodecName(const char* codec_name); | 150 MEDIA_EXPORT int32_t HashCodecName(const char* codec_name); |
| 148 | 151 |
| 149 } // namespace media | 152 } // namespace media |
| 150 | 153 |
| 151 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 154 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
| OLD | NEW |