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

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

Issue 11092054: Teach BindToLoop to create callbacks that accept scoped parameters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: xhwang CR Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « media/base/bind_to_loop_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 mismatching_enums) 91 mismatching_enums)
92 COMPILE_ASSERT_MATCHING_ENUM(Unspecified); 92 COMPILE_ASSERT_MATCHING_ENUM(Unspecified);
93 COMPILE_ASSERT_MATCHING_ENUM(Anonymous); 93 COMPILE_ASSERT_MATCHING_ENUM(Anonymous);
94 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials); 94 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials);
95 #undef COMPILE_ASSERT_MATCHING_ENUM 95 #undef COMPILE_ASSERT_MATCHING_ENUM
96 96
97 #define BIND_TO_RENDER_LOOP(function) \ 97 #define BIND_TO_RENDER_LOOP(function) \
98 media::BindToLoop(main_loop_->message_loop_proxy(), base::Bind( \ 98 media::BindToLoop(main_loop_->message_loop_proxy(), base::Bind( \
99 function, AsWeakPtr())) 99 function, AsWeakPtr()))
100 100
101 #define BIND_TO_RENDER_LOOP_2(function, arg1, arg2) \
102 media::BindToLoop(main_loop_->message_loop_proxy(), base::Bind( \
103 function, AsWeakPtr(), arg1, arg2))
104
101 static WebKit::WebTimeRanges ConvertToWebTimeRanges( 105 static WebKit::WebTimeRanges ConvertToWebTimeRanges(
102 const media::Ranges<base::TimeDelta>& ranges) { 106 const media::Ranges<base::TimeDelta>& ranges) {
103 WebKit::WebTimeRanges result(ranges.size()); 107 WebKit::WebTimeRanges result(ranges.size());
104 for (size_t i = 0; i < ranges.size(); i++) { 108 for (size_t i = 0; i < ranges.size(); i++) {
105 result[i].start = ranges.start(i).InSecondsF(); 109 result[i].start = ranges.start(i).InSecondsF();
106 result[i].end = ranges.end(i).InSecondsF(); 110 result[i].end = ranges.end(i).InSecondsF();
107 } 111 }
108 return result; 112 return result;
109 } 113 }
110 114
111 // TODO(acolwell): Investigate whether the key_system & session_id parameters 115 // TODO(acolwell): Investigate whether the key_system & session_id parameters
112 // are really necessary. 116 // are really necessary.
113 typedef base::Callback<void(const std::string&, 117 typedef base::Callback<void(const std::string&,
114 const std::string&, 118 const std::string&,
115 scoped_array<uint8>, 119 scoped_array<uint8>,
116 int)> OnNeedKeyCB; 120 int)> OnNeedKeyCB;
117 121
118 static void OnDemuxerNeedKeyTrampoline(
119 const scoped_refptr<base::MessageLoopProxy>& message_loop,
120 const OnNeedKeyCB& need_key_cb,
121 scoped_array<uint8> init_data,
122 int init_data_size) {
123 message_loop->PostTask(FROM_HERE, base::Bind(
124 need_key_cb, "", "", base::Passed(&init_data), init_data_size));
125 }
126
127 WebMediaPlayerImpl::WebMediaPlayerImpl( 122 WebMediaPlayerImpl::WebMediaPlayerImpl(
128 WebKit::WebFrame* frame, 123 WebKit::WebFrame* frame,
129 WebKit::WebMediaPlayerClient* client, 124 WebKit::WebMediaPlayerClient* client,
130 base::WeakPtr<WebMediaPlayerDelegate> delegate, 125 base::WeakPtr<WebMediaPlayerDelegate> delegate,
131 media::FilterCollection* collection, 126 media::FilterCollection* collection,
132 WebKit::WebAudioSourceProvider* audio_source_provider, 127 WebKit::WebAudioSourceProvider* audio_source_provider,
133 media::AudioRendererSink* audio_renderer_sink, 128 media::AudioRendererSink* audio_renderer_sink,
134 media::MessageLoopFactory* message_loop_factory, 129 media::MessageLoopFactory* message_loop_factory,
135 MediaStreamClient* media_stream_client, 130 MediaStreamClient* media_stream_client,
136 media::MediaLog* media_log) 131 media::MediaLog* media_log)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 filter_collection_.get())) { 263 filter_collection_.get())) {
269 supports_save_ = false; 264 supports_save_ = false;
270 StartPipeline(); 265 StartPipeline();
271 return; 266 return;
272 } 267 }
273 268
274 // Media source pipelines can start immediately. 269 // Media source pipelines can start immediately.
275 if (!url.isEmpty() && url == GetClient()->sourceURL()) { 270 if (!url.isEmpty() && url == GetClient()->sourceURL()) {
276 chunk_demuxer_ = new media::ChunkDemuxer( 271 chunk_demuxer_ = new media::ChunkDemuxer(
277 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 272 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
278 base::Bind(&OnDemuxerNeedKeyTrampoline, 273 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""));
279 main_loop_->message_loop_proxy(),
280 base::Bind(&WebMediaPlayerImpl::OnNeedKey, AsWeakPtr())));
281 274
282 BuildMediaSourceCollection(chunk_demuxer_, 275 BuildMediaSourceCollection(chunk_demuxer_,
283 message_loop_factory_.get(), 276 message_loop_factory_.get(),
284 filter_collection_.get(), 277 filter_collection_.get(),
285 &decryptor_); 278 &decryptor_);
286 supports_save_ = false; 279 supports_save_ = false;
287 StartPipeline(); 280 StartPipeline();
288 return; 281 return;
289 } 282 }
290 283
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 return audio_source_provider_; 1177 return audio_source_provider_;
1185 } 1178 }
1186 1179
1187 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 1180 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
1188 DCHECK_EQ(main_loop_, MessageLoop::current()); 1181 DCHECK_EQ(main_loop_, MessageLoop::current());
1189 incremented_externally_allocated_memory_ = true; 1182 incremented_externally_allocated_memory_ = true;
1190 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 1183 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
1191 } 1184 }
1192 1185
1193 } // namespace webkit_media 1186 } // namespace webkit_media
OLDNEW
« no previous file with comments | « media/base/bind_to_loop_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698