Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 1735803002: Implemented passing media track info from ffmpeg into blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wolenetz@ CR feedback + better track info extraction in ffmpeg Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 18863e657b80f29ffe75fad5673d3c9474a93b52..d0e4a63a1af1d21784405608665ad09d9780b315 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -27,6 +27,7 @@
#include "media/base/decrypt_config.h"
#include "media/base/limits.h"
#include "media/base/media_log.h"
+#include "media/base/media_tracks.h"
#include "media/base/timestamp_constants.h"
#include "media/ffmpeg/ffmpeg_common.h"
#include "media/filters/ffmpeg_aac_bitstream_converter.h"
@@ -741,6 +742,7 @@ FFmpegDemuxer::FFmpegDemuxer(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
DataSource* data_source,
const EncryptedMediaInitDataCB& encrypted_media_init_data_cb,
+ const MediaTracksUpdatedCB& media_tracks_updated_cb,
const scoped_refptr<MediaLog>& media_log)
: host_(NULL),
task_runner_(task_runner),
@@ -756,9 +758,11 @@ FFmpegDemuxer::FFmpegDemuxer(
text_enabled_(false),
duration_known_(false),
encrypted_media_init_data_cb_(encrypted_media_init_data_cb),
+ media_tracks_updated_cb_(media_tracks_updated_cb),
weak_factory_(this) {
DCHECK(task_runner_.get());
DCHECK(data_source_);
+ DCHECK(!media_tracks_updated_cb_.is_null());
}
FFmpegDemuxer::~FFmpegDemuxer() {}
@@ -1054,6 +1058,7 @@ void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb,
}
}
+ scoped_ptr<MediaTracks> media_tracks(new MediaTracks());
AVStream* audio_stream = NULL;
AudioDecoderConfig audio_config;
AVStream* video_stream = NULL;
@@ -1123,6 +1128,18 @@ void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb,
continue;
}
+ AVDictionaryEntry* lang_tag =
+ av_dict_get(stream->metadata, "language", NULL, 0);
+ std::string track_language = "und";
+ if (lang_tag && lang_tag->value)
+ track_language = lang_tag->value;
+
+ std::string track_label = "";
+ AVDictionaryEntry* handler_tag =
+ av_dict_get(stream->metadata, "handler_name", NULL, 0);
+ if (handler_tag && handler_tag->value)
+ track_label = handler_tag->value;
+
// Note when we find our audio/video stream (we only want one of each) and
// record src= playback UMA stats for the stream's decoder config.
if (codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -1130,11 +1147,17 @@ void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb,
audio_stream = stream;
audio_config = streams_[i]->audio_decoder_config();
RecordAudioCodecStats(audio_config);
+
+ media_tracks->AddAudioTrack(audio_config, base::UintToString(stream->id),
+ "main", track_label, track_language);
} else if (codec_type == AVMEDIA_TYPE_VIDEO) {
CHECK(!video_stream);
video_stream = stream;
video_config = streams_[i]->video_decoder_config();
RecordVideoCodecStats(video_config, stream->codec->color_range);
+
+ media_tracks->AddVideoTrack(video_config, base::UintToString(stream->id),
+ "main", track_label, track_language);
}
max_duration = std::max(max_duration, streams_[i]->duration());
@@ -1320,6 +1343,8 @@ void FFmpegDemuxer::OnFindStreamInfoDone(const PipelineStatusCB& status_cb,
media_log_->SetTimeProperty("start_time", start_time_);
media_log_->SetIntegerProperty("bitrate", bitrate_);
+ media_tracks_updated_cb_.Run(std::move(media_tracks));
+
status_cb.Run(PIPELINE_OK);
}
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698