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..1248974714eda608dfec7e03a48c1af9f0663e93 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,36 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer, |
| type_ = VIDEO; |
| AVStreamToVideoDecoderConfig(stream, &video_config_, true); |
| is_encrypted = video_config_.is_encrypted(); |
| + |
| + // Extract rotation metadata |
| + 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); |
| + |
| + // Check that it is only a 90 degree increment |
| + DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || |
|
scherkus (not reviewing)
2014/07/07 22:41:11
if you gracefully handle it below there's no need
|
| + rotation == 270); |
| + |
| + // Translate to the appropriate enum |
|
scherkus (not reviewing)
2014/07/07 22:41:11
comment isn't very helpful -- I'd remove it
|
| + switch (rotation) { |
| + case 90: |
| + set_video_rotation(VIDEO_ROTATION_90); |
| + 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); |
| + LOG(ERROR) << "Unsupported video rotation metadata: " << rotation; |
| + break; |
| + } |
| + |
| break; |
| case AVMEDIA_TYPE_SUBTITLE: |
| type_ = TEXT; |