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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 13419002: Media Source dispatches inband text tracks (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: incorporated aaron's comments Created 7 years, 7 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 unified diff | Download patch
OLDNEW
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 #include "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/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 27 matching lines...) Expand all
38 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" 38 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
39 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 39 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
40 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 40 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
41 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" 41 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
45 #include "v8/include/v8.h" 45 #include "v8/include/v8.h"
46 #include "webkit/compositor_bindings/web_layer_impl.h" 46 #include "webkit/compositor_bindings/web_layer_impl.h"
47 #include "webkit/media/buffered_data_source.h" 47 #include "webkit/media/buffered_data_source.h"
48 #include "webkit/media/texttrack_impl.h"
48 #include "webkit/media/webaudiosourceprovider_impl.h" 49 #include "webkit/media/webaudiosourceprovider_impl.h"
50 #include "webkit/media/webinbandtexttrack_impl.h"
49 #include "webkit/media/webmediaplayer_delegate.h" 51 #include "webkit/media/webmediaplayer_delegate.h"
50 #include "webkit/media/webmediaplayer_params.h" 52 #include "webkit/media/webmediaplayer_params.h"
51 #include "webkit/media/webmediaplayer_util.h" 53 #include "webkit/media/webmediaplayer_util.h"
52 #include "webkit/media/webmediasourceclient_impl.h" 54 #include "webkit/media/webmediasourceclient_impl.h"
53 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 55 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
54 56
55 using WebKit::WebCanvas; 57 using WebKit::WebCanvas;
56 using WebKit::WebMediaPlayer; 58 using WebKit::WebMediaPlayer;
57 using WebKit::WebRect; 59 using WebKit::WebRect;
58 using WebKit::WebSize; 60 using WebKit::WebSize;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 media_log_(params.media_log()), 141 media_log_(params.media_log()),
140 accelerated_compositing_reported_(false), 142 accelerated_compositing_reported_(false),
141 incremented_externally_allocated_memory_(false), 143 incremented_externally_allocated_memory_(false),
142 gpu_factories_(params.gpu_factories()), 144 gpu_factories_(params.gpu_factories()),
143 is_local_source_(false), 145 is_local_source_(false),
144 supports_save_(true), 146 supports_save_(true),
145 starting_(false), 147 starting_(false),
146 chunk_demuxer_(NULL), 148 chunk_demuxer_(NULL),
147 pending_repaint_(false), 149 pending_repaint_(false),
148 pending_size_change_(false), 150 pending_size_change_(false),
149 video_frame_provider_client_(NULL) { 151 video_frame_provider_client_(NULL),
152 text_track_index_(0) {
150 media_log_->AddEvent( 153 media_log_->AddEvent(
151 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 154 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
152 155
153 CHECK(media_thread_.Start()); 156 CHECK(media_thread_.Start());
154 pipeline_.reset(new media::Pipeline( 157 pipeline_.reset(new media::Pipeline(
155 media_thread_.message_loop_proxy(), media_log_)); 158 media_thread_.message_loop_proxy(), media_log_));
156 159
157 // Let V8 know we started new thread if we did not do it yet. 160 // Let V8 know we started new thread if we did not do it yet.
158 // Made separate task to avoid deletion of player currently being created. 161 // Made separate task to avoid deletion of player currently being created.
159 // Also, delaying GC until after player starts gets rid of starting lag -- 162 // Also, delaying GC until after player starts gets rid of starting lag --
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); 984 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_);
982 if (init_data_type_.empty()) 985 if (init_data_type_.empty())
983 init_data_type_ = type; 986 init_data_type_ = type;
984 987
985 GetClient()->keyNeeded(WebString::fromUTF8(key_system), 988 GetClient()->keyNeeded(WebString::fromUTF8(key_system),
986 WebString::fromUTF8(session_id), 989 WebString::fromUTF8(session_id),
987 init_data.get(), 990 init_data.get(),
988 init_data_size); 991 init_data_size);
989 } 992 }
990 993
994 scoped_ptr<media::TextTrack>
995 WebMediaPlayerImpl::OnTextTrack(media::TextKind kind,
996 const std::string& label,
997 const std::string& language) {
998 typedef WebInbandTextTrackImpl::Kind webkind_t;
999 const webkind_t webkind = static_cast<webkind_t>(kind);
1000 const WebKit::WebString weblabel = WebKit::WebString::fromUTF8(label);
1001 const WebKit::WebString weblanguage = WebKit::WebString::fromUTF8(language);
1002
1003 // TODO(matthewjheaney): resolve lifetime issues for text_track_.
1004 // Note that the text track object is adopted by its client, and so
1005 // it does get destroyed during teardown of the tracks, and
1006 // therefore there's no memory leak. However, there is the issue of
1007 // lifetime, since we share a pointer to this text track object with
1008 // its (owning) client.
1009
1010 WebInbandTextTrackImpl* const text_track =
1011 new WebInbandTextTrackImpl(webkind, weblabel, weblanguage,
1012 text_track_index_++);
1013 GetClient()->addTextTrack(text_track);
1014
1015 // TODO(matthewjheaney): give text_cb ownership of text_track.
1016 // This means webkit will not adopt text_track.
1017 TextTrackImpl* const text_cb = new TextTrackImpl(text_track->client());
acolwell GONE FROM CHROMIUM 2013/05/10 18:41:39 nit: Just inline this below.
Matthew Heaney (Chromium) 2013/05/11 07:29:13 Done.
1018
1019 return scoped_ptr<media::TextTrack>(text_cb);
1020 }
1021
991 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ 1022 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
992 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ 1023 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \
993 static_cast<int>(media::Decryptor::k ## name), \ 1024 static_cast<int>(media::Decryptor::k ## name), \
994 mismatching_enums) 1025 mismatching_enums)
995 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); 1026 COMPILE_ASSERT_MATCHING_ENUM(UnknownError);
996 COMPILE_ASSERT_MATCHING_ENUM(ClientError); 1027 COMPILE_ASSERT_MATCHING_ENUM(ClientError);
997 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); 1028 COMPILE_ASSERT_MATCHING_ENUM(ServiceError);
998 COMPILE_ASSERT_MATCHING_ENUM(OutputError); 1029 COMPILE_ASSERT_MATCHING_ENUM(OutputError);
999 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); 1030 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError);
1000 COMPILE_ASSERT_MATCHING_ENUM(DomainError); 1031 COMPILE_ASSERT_MATCHING_ENUM(DomainError);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""))); 1107 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", "")));
1077 } else { 1108 } else {
1078 DCHECK(!chunk_demuxer_); 1109 DCHECK(!chunk_demuxer_);
1079 DCHECK(!data_source_); 1110 DCHECK(!data_source_);
1080 1111
1081 scoped_ptr<WebKit::WebMediaSource> ms(media_source); 1112 scoped_ptr<WebKit::WebMediaSource> ms(media_source);
1082 chunk_demuxer_ = new media::ChunkDemuxer( 1113 chunk_demuxer_ = new media::ChunkDemuxer(
1083 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, 1114 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened,
1084 base::Passed(&ms)), 1115 base::Passed(&ms)),
1085 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), 1116 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""),
1117 base::Bind(&WebMediaPlayerImpl::OnTextTrack, base::Unretained(this)),
1086 base::Bind(&LogMediaSourceError, media_log_)); 1118 base::Bind(&LogMediaSourceError, media_log_));
1087 demuxer_.reset(chunk_demuxer_); 1119 demuxer_.reset(chunk_demuxer_);
1088 1120
1089 // Disable GpuVideoDecoder creation until it supports codec config changes. 1121 // Disable GpuVideoDecoder creation until it supports codec config changes.
1090 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. 1122 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed.
1091 gpu_factories_ = NULL; 1123 gpu_factories_ = NULL;
1092 } 1124 }
1093 1125
1094 scoped_ptr<media::FilterCollection> filter_collection( 1126 scoped_ptr<media::FilterCollection> filter_collection(
1095 new media::FilterCollection()); 1127 new media::FilterCollection());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 1299
1268 if (pending_repaint_) 1300 if (pending_repaint_)
1269 return; 1301 return;
1270 1302
1271 pending_repaint_ = true; 1303 pending_repaint_ = true;
1272 main_loop_->PostTask(FROM_HERE, base::Bind( 1304 main_loop_->PostTask(FROM_HERE, base::Bind(
1273 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1305 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1274 } 1306 }
1275 1307
1276 } // namespace webkit_media 1308 } // namespace webkit_media
OLDNEW
« webkit/media/texttrack_impl.h ('K') | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698