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

Side by Side Diff: content/renderer/media/webmediaplayer_impl.cc

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix compile errors 11/21 #6 Created 7 years 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 unified diff | Download patch
« no previous file with comments | « content/renderer/media/webmediaplayer_impl.h ('k') | media/base/demuxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/renderer/media/webmediaplayer_impl.h" 5 #include "content/renderer/media/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 20 matching lines...) Expand all
31 #include "content/renderer/media/webmediasource_impl.h" 31 #include "content/renderer/media/webmediasource_impl.h"
32 #include "content/renderer/pepper/pepper_webplugin_impl.h" 32 #include "content/renderer/pepper/pepper_webplugin_impl.h"
33 #include "gpu/GLES2/gl2extchromium.h" 33 #include "gpu/GLES2/gl2extchromium.h"
34 #include "media/audio/null_audio_sink.h" 34 #include "media/audio/null_audio_sink.h"
35 #include "media/base/bind_to_loop.h" 35 #include "media/base/bind_to_loop.h"
36 #include "media/base/filter_collection.h" 36 #include "media/base/filter_collection.h"
37 #include "media/base/limits.h" 37 #include "media/base/limits.h"
38 #include "media/base/media_log.h" 38 #include "media/base/media_log.h"
39 #include "media/base/media_switches.h" 39 #include "media/base/media_switches.h"
40 #include "media/base/pipeline.h" 40 #include "media/base/pipeline.h"
41 #include "media/base/text_renderer.h"
41 #include "media/base/video_frame.h" 42 #include "media/base/video_frame.h"
42 #include "media/filters/audio_renderer_impl.h" 43 #include "media/filters/audio_renderer_impl.h"
43 #include "media/filters/chunk_demuxer.h" 44 #include "media/filters/chunk_demuxer.h"
44 #include "media/filters/ffmpeg_audio_decoder.h" 45 #include "media/filters/ffmpeg_audio_decoder.h"
45 #include "media/filters/ffmpeg_demuxer.h" 46 #include "media/filters/ffmpeg_demuxer.h"
46 #include "media/filters/ffmpeg_video_decoder.h" 47 #include "media/filters/ffmpeg_video_decoder.h"
47 #include "media/filters/gpu_video_accelerator_factories.h" 48 #include "media/filters/gpu_video_accelerator_factories.h"
48 #include "media/filters/gpu_video_decoder.h" 49 #include "media/filters/gpu_video_decoder.h"
49 #include "media/filters/opus_audio_decoder.h" 50 #include "media/filters/opus_audio_decoder.h"
50 #include "media/filters/video_renderer_base.h" 51 #include "media/filters/video_renderer_base.h"
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 if (init_data_type_.empty()) 987 if (init_data_type_.empty())
987 init_data_type_ = type; 988 init_data_type_ = type;
988 989
989 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; 990 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0];
990 GetClient()->keyNeeded(WebString(), 991 GetClient()->keyNeeded(WebString(),
991 WebString(), 992 WebString(),
992 init_data_ptr, 993 init_data_ptr,
993 init_data.size()); 994 init_data.size());
994 } 995 }
995 996
996 scoped_ptr<media::TextTrack> 997 void WebMediaPlayerImpl::OnAddTextTrack(
997 WebMediaPlayerImpl::OnTextTrack(media::TextKind kind, 998 const media::TextTrackConfig& config,
998 const std::string& label, 999 const media::AddTextTrackDoneCB& done_cb) {
999 const std::string& language) { 1000 DCHECK(main_loop_->BelongsToCurrentThread());
1000 typedef WebInbandTextTrackImpl::Kind webkind_t;
1001 const webkind_t webkind = static_cast<webkind_t>(kind);
1002 const blink::WebString weblabel = blink::WebString::fromUTF8(label);
1003 const blink::WebString weblanguage = blink::WebString::fromUTF8(language);
1004 1001
1005 WebInbandTextTrackImpl* const text_track = 1002 const WebInbandTextTrackImpl::Kind web_kind =
1006 new WebInbandTextTrackImpl(webkind, weblabel, weblanguage, 1003 static_cast<WebInbandTextTrackImpl::Kind>(config.kind());
1007 text_track_index_++); 1004 const blink::WebString web_label =
1005 blink::WebString::fromUTF8(config.label());
1006 const blink::WebString web_language =
1007 blink::WebString::fromUTF8(config.language());
1008 1008
1009 return scoped_ptr<media::TextTrack>(new TextTrackImpl(GetClient(), 1009 scoped_ptr<WebInbandTextTrackImpl> web_inband_text_track(
1010 text_track)); 1010 new WebInbandTextTrackImpl(web_kind, web_label, web_language,
1011 text_track_index_++));
1012
1013 scoped_ptr<media::TextTrack> text_track(
1014 new TextTrackImpl(main_loop_, GetClient(), web_inband_text_track.Pass()));
1015
1016 done_cb.Run(text_track.Pass());
1011 } 1017 }
1012 1018
1013 void WebMediaPlayerImpl::OnKeyError(const std::string& session_id, 1019 void WebMediaPlayerImpl::OnKeyError(const std::string& session_id,
1014 media::MediaKeys::KeyError error_code, 1020 media::MediaKeys::KeyError error_code,
1015 int system_code) { 1021 int system_code) {
1016 DCHECK(main_loop_->BelongsToCurrentThread()); 1022 DCHECK(main_loop_->BelongsToCurrentThread());
1017 1023
1018 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", 1024 EmeUMAHistogramEnumeration(current_key_system_, "KeyError",
1019 error_code, media::MediaKeys::kMaxKeyError); 1025 error_code, media::MediaKeys::kMaxKeyError);
1020 1026
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 DCHECK(data_source_); 1090 DCHECK(data_source_);
1085 1091
1086 demuxer_.reset(new media::FFmpegDemuxer( 1092 demuxer_.reset(new media::FFmpegDemuxer(
1087 media_loop_, data_source_.get(), 1093 media_loop_, data_source_.get(),
1088 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey), 1094 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey),
1089 media_log_)); 1095 media_log_));
1090 } else { 1096 } else {
1091 DCHECK(!chunk_demuxer_); 1097 DCHECK(!chunk_demuxer_);
1092 DCHECK(!data_source_); 1098 DCHECK(!data_source_);
1093 1099
1094 media::AddTextTrackCB add_text_track_cb;
1095
1096 if (cmd_line->HasSwitch(switches::kEnableInbandTextTracks)) {
1097 add_text_track_cb =
1098 base::Bind(&WebMediaPlayerImpl::OnTextTrack, base::Unretained(this));
1099 }
1100
1101 chunk_demuxer_ = new media::ChunkDemuxer( 1100 chunk_demuxer_ = new media::ChunkDemuxer(
1102 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 1101 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
1103 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey), 1102 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey),
1104 add_text_track_cb,
1105 base::Bind(&LogMediaSourceError, media_log_)); 1103 base::Bind(&LogMediaSourceError, media_log_));
1106 demuxer_.reset(chunk_demuxer_); 1104 demuxer_.reset(chunk_demuxer_);
1107 1105
1108 #if !defined(OS_CHROMEOS) 1106 #if !defined(OS_CHROMEOS)
1109 // Disable GpuVideoDecoder creation on platforms other than CrOS until 1107 // Disable GpuVideoDecoder creation on platforms other than CrOS until
1110 // they support codec config changes. 1108 // they support codec config changes.
1111 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. 1109 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed.
1112 gpu_factories_ = NULL; 1110 gpu_factories_ = NULL;
1113 #endif 1111 #endif
1114 1112
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 scoped_ptr<media::VideoRenderer> video_renderer( 1160 scoped_ptr<media::VideoRenderer> video_renderer(
1163 new media::VideoRendererBase( 1161 new media::VideoRendererBase(
1164 media_loop_, 1162 media_loop_,
1165 video_decoders.Pass(), 1163 video_decoders.Pass(),
1166 set_decryptor_ready_cb, 1164 set_decryptor_ready_cb,
1167 base::Bind(&WebMediaPlayerImpl::FrameReady, base::Unretained(this)), 1165 base::Bind(&WebMediaPlayerImpl::FrameReady, base::Unretained(this)),
1168 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::SetOpaque), 1166 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::SetOpaque),
1169 true)); 1167 true));
1170 filter_collection->SetVideoRenderer(video_renderer.Pass()); 1168 filter_collection->SetVideoRenderer(video_renderer.Pass());
1171 1169
1170 if (cmd_line->HasSwitch(switches::kEnableInbandTextTracks)) {
1171 scoped_ptr<media::TextRenderer> text_renderer(
1172 new media::TextRenderer(
1173 media_loop_,
1174 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnAddTextTrack)));
1175
1176 filter_collection->SetTextRenderer(text_renderer.Pass());
1177 }
1178
1172 // ... and we're ready to go! 1179 // ... and we're ready to go!
1173 starting_ = true; 1180 starting_ = true;
1174 pipeline_->Start( 1181 pipeline_->Start(
1175 filter_collection.Pass(), 1182 filter_collection.Pass(),
1176 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineEnded), 1183 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineEnded),
1177 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineError), 1184 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineError),
1178 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek), 1185 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek),
1179 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingState), 1186 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingState),
1180 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChange)); 1187 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChange));
1181 } 1188 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 // The |current_frame_| wasn't painted, it is being replaced, and we haven't 1323 // The |current_frame_| wasn't painted, it is being replaced, and we haven't
1317 // even gotten the chance to request a repaint for it yet. Mark it as dropped. 1324 // even gotten the chance to request a repaint for it yet. Mark it as dropped.
1318 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); 1325 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped");
1319 DVLOG(1) << "Frame dropped before being painted: " 1326 DVLOG(1) << "Frame dropped before being painted: "
1320 << current_frame_->GetTimestamp().InSecondsF(); 1327 << current_frame_->GetTimestamp().InSecondsF();
1321 if (frames_dropped_before_paint_ < kuint32max) 1328 if (frames_dropped_before_paint_ < kuint32max)
1322 frames_dropped_before_paint_++; 1329 frames_dropped_before_paint_++;
1323 } 1330 }
1324 1331
1325 } // namespace content 1332 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_impl.h ('k') | media/base/demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698