Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 28 matching lines...) Expand all Loading... | |
| 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/webaudiosourceprovider_impl.h" | 48 #include "webkit/media/webaudiosourceprovider_impl.h" |
| 49 #include "webkit/media/webinbandtexttrack_impl.h" | |
| 49 #include "webkit/media/webmediaplayer_delegate.h" | 50 #include "webkit/media/webmediaplayer_delegate.h" |
| 50 #include "webkit/media/webmediaplayer_params.h" | 51 #include "webkit/media/webmediaplayer_params.h" |
| 51 #include "webkit/media/webmediaplayer_util.h" | 52 #include "webkit/media/webmediaplayer_util.h" |
| 52 #include "webkit/media/webmediasourceclient_impl.h" | 53 #include "webkit/media/webmediasourceclient_impl.h" |
| 54 #include "webkit/media/webtexttrack_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; |
| 59 using WebKit::WebString; | 61 using WebKit::WebString; |
| 60 using media::PipelineStatus; | 62 using media::PipelineStatus; |
| 61 | 63 |
| 62 namespace { | 64 namespace { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); | 983 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); |
| 981 if (init_data_type_.empty()) | 984 if (init_data_type_.empty()) |
| 982 init_data_type_ = type; | 985 init_data_type_ = type; |
| 983 | 986 |
| 984 GetClient()->keyNeeded(WebString::fromUTF8(key_system), | 987 GetClient()->keyNeeded(WebString::fromUTF8(key_system), |
| 985 WebString::fromUTF8(session_id), | 988 WebString::fromUTF8(session_id), |
| 986 init_data.get(), | 989 init_data.get(), |
| 987 init_data_size); | 990 init_data_size); |
| 988 } | 991 } |
| 989 | 992 |
| 993 media::TextTrack* | |
| 994 WebMediaPlayerImpl::OnTextTrack(media::TextKind kind, | |
| 995 const std::string& label, | |
| 996 const std::string& language) { | |
| 997 typedef WebInbandTextTrackImpl::Kind webkind_t; | |
| 998 const webkind_t webkind = static_cast<webkind_t>(kind); | |
| 999 const WebKit::WebString weblabel = WebKit::WebString::fromUTF8(label); | |
| 1000 const WebKit::WebString weblanguage = WebKit::WebString::fromUTF8(language); | |
| 1001 | |
| 1002 // TODO(matthewjheaney): resolve lifetime issues for text_track_. | |
| 1003 // Note that the text track object is adopted by its client, and so | |
| 1004 // it does get destroyed during teardown of the tracks, and | |
| 1005 // therefore there's no memory leak. However, there is the issue of | |
| 1006 // lifetime, since we share a pointer to this text track object with | |
| 1007 // its (owning) client. | |
| 1008 | |
| 1009 WebInbandTextTrackImpl* const text_track = | |
| 1010 new WebInbandTextTrackImpl(webkind, weblabel, weblanguage, | |
| 1011 text_track_index_++); | |
| 1012 GetClient()->addTextTrack(text_track); | |
| 1013 | |
| 1014 // TODO(matthewjheaney): better name for WebTextTrackImpl? | |
| 1015 WebTextTrackImpl* const text_cb = new WebTextTrackImpl(text_track->client()); | |
|
acolwell GONE FROM CHROMIUM
2013/05/10 02:22:08
I think you need to be careful about ownership her
Matthew Heaney (Chromium)
2013/05/10 05:21:08
OK, that makes sense. I'll make the necessary cha
| |
| 1016 | |
| 1017 // TODO(matthewjheaney): need to keep record of created text tracks? | |
| 1018 //text_tracks_.insert(text_cb); | |
| 1019 | |
| 1020 // TODO(matthewjheaney): for now, rely on caller to destroy text_cb. | |
| 1021 return text_cb; | |
| 1022 } | |
| 1023 | |
| 990 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 1024 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
| 991 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ | 1025 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayerClient::name) == \ |
| 992 static_cast<int>(media::Decryptor::k ## name), \ | 1026 static_cast<int>(media::Decryptor::k ## name), \ |
| 993 mismatching_enums) | 1027 mismatching_enums) |
| 994 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); | 1028 COMPILE_ASSERT_MATCHING_ENUM(UnknownError); |
| 995 COMPILE_ASSERT_MATCHING_ENUM(ClientError); | 1029 COMPILE_ASSERT_MATCHING_ENUM(ClientError); |
| 996 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); | 1030 COMPILE_ASSERT_MATCHING_ENUM(ServiceError); |
| 997 COMPILE_ASSERT_MATCHING_ENUM(OutputError); | 1031 COMPILE_ASSERT_MATCHING_ENUM(OutputError); |
| 998 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); | 1032 COMPILE_ASSERT_MATCHING_ENUM(HardwareChangeError); |
| 999 COMPILE_ASSERT_MATCHING_ENUM(DomainError); | 1033 COMPILE_ASSERT_MATCHING_ENUM(DomainError); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1075 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""))); | 1109 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""))); |
| 1076 } else { | 1110 } else { |
| 1077 DCHECK(!chunk_demuxer_); | 1111 DCHECK(!chunk_demuxer_); |
| 1078 DCHECK(!data_source_); | 1112 DCHECK(!data_source_); |
| 1079 | 1113 |
| 1080 scoped_ptr<WebKit::WebMediaSource> ms(media_source); | 1114 scoped_ptr<WebKit::WebMediaSource> ms(media_source); |
| 1081 chunk_demuxer_ = new media::ChunkDemuxer( | 1115 chunk_demuxer_ = new media::ChunkDemuxer( |
| 1082 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, | 1116 BIND_TO_RENDER_LOOP_1(&WebMediaPlayerImpl::OnDemuxerOpened, |
| 1083 base::Passed(&ms)), | 1117 base::Passed(&ms)), |
| 1084 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), | 1118 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), |
| 1119 // TODO(matthewjheaney): need confirmation that Unretained is OK here | |
| 1120 base::Bind(&WebMediaPlayerImpl::OnTextTrack, base::Unretained(this)), | |
|
acolwell GONE FROM CHROMIUM
2013/05/10 02:22:08
Yes. this is fine.
Matthew Heaney (Chromium)
2013/05/10 05:21:08
Done.
| |
| 1085 base::Bind(&LogMediaSourceError, media_log_)); | 1121 base::Bind(&LogMediaSourceError, media_log_)); |
| 1086 demuxer_.reset(chunk_demuxer_); | 1122 demuxer_.reset(chunk_demuxer_); |
| 1087 | 1123 |
| 1088 // Disable GpuVideoDecoder creation until it supports codec config changes. | 1124 // Disable GpuVideoDecoder creation until it supports codec config changes. |
| 1089 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. | 1125 // TODO(acolwell): Remove this once http://crbug.com/151045 is fixed. |
| 1090 gpu_factories_ = NULL; | 1126 gpu_factories_ = NULL; |
| 1091 } | 1127 } |
| 1092 | 1128 |
| 1093 scoped_ptr<media::FilterCollection> filter_collection( | 1129 scoped_ptr<media::FilterCollection> filter_collection( |
| 1094 new media::FilterCollection()); | 1130 new media::FilterCollection()); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 | 1302 |
| 1267 if (pending_repaint_) | 1303 if (pending_repaint_) |
| 1268 return; | 1304 return; |
| 1269 | 1305 |
| 1270 pending_repaint_ = true; | 1306 pending_repaint_ = true; |
| 1271 main_loop_->PostTask(FROM_HERE, base::Bind( | 1307 main_loop_->PostTask(FROM_HERE, base::Bind( |
| 1272 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1308 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
| 1273 } | 1309 } |
| 1274 | 1310 |
| 1275 } // namespace webkit_media | 1311 } // namespace webkit_media |
| OLD | NEW |