Chromium Code Reviews| Index: media/filters/ffmpeg_demuxer.cc |
| diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc |
| index 05fa340ad55147d5b6d0934f35ea1b73c71d665d..3ddcdb6b3c9f95fc5cd3f01e3988fc3ec1a00949 100644 |
| --- a/media/filters/ffmpeg_demuxer.cc |
| +++ b/media/filters/ffmpeg_demuxer.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/message_loop/message_loop_proxy.h" |
| #include "base/metrics/sparse_histogram.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/sys_byteorder.h" |
| @@ -97,6 +98,8 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer, |
| DCHECK(demuxer_); |
| bool is_encrypted = false; |
| + int rotation = 0; |
| + AVDictionaryEntry* rotation_entry = NULL; |
| // Determine our media format. |
| switch (stream->codec->codec_type) { |
| @@ -109,6 +112,31 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer, |
| type_ = VIDEO; |
| AVStreamToVideoDecoderConfig(stream, &video_config_, true); |
| is_encrypted = video_config_.is_encrypted(); |
| + |
| + // Extract rotation metadata |
|
scherkus (not reviewing)
2014/07/07 23:58:45
add period to ... or just remove the comment entir
|
| + rotation_entry = av_dict_get(stream->metadata, "rotate", NULL, 0); |
| + if (rotation_entry && rotation_entry->value && rotation_entry->value[0]) |
| + base::StringToInt(rotation_entry->value, &rotation); |
| + |
| + switch (rotation) { |
| + case 90: |
| + set_video_rotation(VIDEO_ROTATION_90); |
|
scherkus (not reviewing)
2014/07/07 23:58:45
instead of these setters, just set video_rotation_
|
| + break; |
| + case 180: |
| + set_video_rotation(VIDEO_ROTATION_180); |
| + break; |
| + case 270: |
| + set_video_rotation(VIDEO_ROTATION_270); |
| + break; |
| + case 0: |
| + set_video_rotation(VIDEO_ROTATION_0); |
| + break; |
| + default: |
| + set_video_rotation(VIDEO_ROTATION_0); |
|
scherkus (not reviewing)
2014/07/07 23:58:45
nit: since you'll have initialized this in the cto
|
| + LOG(ERROR) << "Unsupported video rotation metadata: " << rotation; |
| + break; |
| + } |
| + |
| break; |
| case AVMEDIA_TYPE_SUBTITLE: |
| type_ = TEXT; |
| @@ -380,6 +408,14 @@ VideoDecoderConfig FFmpegDemuxerStream::video_decoder_config() { |
| return video_config_; |
| } |
| +VideoRotation FFmpegDemuxerStream::video_rotation() { |
| + return video_rotation_; |
| +} |
| + |
| +void FFmpegDemuxerStream::set_video_rotation(VideoRotation video_rotation) { |
| + video_rotation_ = video_rotation; |
| +} |
| + |
| FFmpegDemuxerStream::~FFmpegDemuxerStream() { |
| DCHECK(!demuxer_); |
| DCHECK(read_cb_.is_null()); |