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

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

Issue 18123002: Migrate webkit/renderer/media/ to content/renderer/media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
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 "webkit/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>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/debug/crash_logging.h" 15 #include "base/debug/crash_logging.h"
16 #include "base/message_loop/message_loop_proxy.h" 16 #include "base/message_loop/message_loop_proxy.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "cc/layers/video_layer.h" 20 #include "cc/layers/video_layer.h"
21 #include "content/renderer/media/buffered_data_source.h"
22 #include "content/renderer/media/texttrack_impl.h"
23 #include "content/renderer/media/webaudiosourceprovider_impl.h"
24 #include "content/renderer/media/webinbandtexttrack_impl.h"
25 #include "content/renderer/media/webmediaplayer_delegate.h"
26 #include "content/renderer/media/webmediaplayer_params.h"
27 #include "content/renderer/media/webmediaplayer_util.h"
28 #include "content/renderer/media/webmediasourceclient_impl.h"
21 #include "gpu/GLES2/gl2extchromium.h" 29 #include "gpu/GLES2/gl2extchromium.h"
22 #include "media/audio/null_audio_sink.h" 30 #include "media/audio/null_audio_sink.h"
23 #include "media/base/bind_to_loop.h" 31 #include "media/base/bind_to_loop.h"
24 #include "media/base/filter_collection.h" 32 #include "media/base/filter_collection.h"
25 #include "media/base/limits.h" 33 #include "media/base/limits.h"
26 #include "media/base/media_log.h" 34 #include "media/base/media_log.h"
27 #include "media/base/media_switches.h" 35 #include "media/base/media_switches.h"
28 #include "media/base/pipeline.h" 36 #include "media/base/pipeline.h"
29 #include "media/base/video_frame.h" 37 #include "media/base/video_frame.h"
30 #include "media/filters/audio_renderer_impl.h" 38 #include "media/filters/audio_renderer_impl.h"
31 #include "media/filters/chunk_demuxer.h" 39 #include "media/filters/chunk_demuxer.h"
32 #include "media/filters/ffmpeg_audio_decoder.h" 40 #include "media/filters/ffmpeg_audio_decoder.h"
33 #include "media/filters/ffmpeg_demuxer.h" 41 #include "media/filters/ffmpeg_demuxer.h"
34 #include "media/filters/ffmpeg_video_decoder.h" 42 #include "media/filters/ffmpeg_video_decoder.h"
35 #include "media/filters/opus_audio_decoder.h" 43 #include "media/filters/opus_audio_decoder.h"
36 #include "media/filters/video_renderer_base.h" 44 #include "media/filters/video_renderer_base.h"
37 #include "media/filters/vpx_video_decoder.h" 45 #include "media/filters/vpx_video_decoder.h"
38 #include "third_party/WebKit/public/platform/WebRect.h" 46 #include "third_party/WebKit/public/platform/WebRect.h"
39 #include "third_party/WebKit/public/platform/WebSize.h" 47 #include "third_party/WebKit/public/platform/WebSize.h"
40 #include "third_party/WebKit/public/platform/WebString.h" 48 #include "third_party/WebKit/public/platform/WebString.h"
41 #include "third_party/WebKit/public/platform/WebURL.h" 49 #include "third_party/WebKit/public/platform/WebURL.h"
42 #include "third_party/WebKit/public/web/WebMediaSource.h" 50 #include "third_party/WebKit/public/web/WebMediaSource.h"
43 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 51 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
44 #include "third_party/WebKit/public/web/WebView.h" 52 #include "third_party/WebKit/public/web/WebView.h"
45 #include "v8/include/v8.h" 53 #include "v8/include/v8.h"
46 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" 54 #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
47 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" 55 #include "webkit/renderer/compositor_bindings/web_layer_impl.h"
48 #include "webkit/renderer/media/buffered_data_source.h"
49 #include "webkit/renderer/media/crypto/key_systems.h" 56 #include "webkit/renderer/media/crypto/key_systems.h"
50 #include "webkit/renderer/media/texttrack_impl.h"
51 #include "webkit/renderer/media/webaudiosourceprovider_impl.h"
52 #include "webkit/renderer/media/webinbandtexttrack_impl.h"
53 #include "webkit/renderer/media/webmediaplayer_delegate.h"
54 #include "webkit/renderer/media/webmediaplayer_params.h"
55 #include "webkit/renderer/media/webmediaplayer_util.h"
56 #include "webkit/renderer/media/webmediasourceclient_impl.h"
57 57
58 using WebKit::WebCanvas; 58 using WebKit::WebCanvas;
59 using WebKit::WebMediaPlayer; 59 using WebKit::WebMediaPlayer;
60 using WebKit::WebRect; 60 using WebKit::WebRect;
61 using WebKit::WebSize; 61 using WebKit::WebSize;
62 using WebKit::WebString; 62 using WebKit::WebString;
63 using media::PipelineStatus; 63 using media::PipelineStatus;
64 using webkit_media::IsSupportedKeySystem;
65 using webkit_media::KeySystemNameForUMA;
66 using webkit_media::ProxyDecryptor;
64 67
65 namespace { 68 namespace {
66 69
67 // Amount of extra memory used by each player instance reported to V8. 70 // Amount of extra memory used by each player instance reported to V8.
68 // It is not exact number -- first, it differs on different platforms, 71 // It is not exact number -- first, it differs on different platforms,
69 // and second, it is very hard to calculate. Instead, use some arbitrary 72 // and second, it is very hard to calculate. Instead, use some arbitrary
70 // value that will cause garbage collection from time to time. We don't want 73 // value that will cause garbage collection from time to time. We don't want
71 // it to happen on every allocation, but don't want 5k players to sit in memory 74 // it to happen on every allocation, but don't want 5k players to sit in memory
72 // either. Looks that chosen constant achieves both goals, at least for audio 75 // either. Looks that chosen constant achieves both goals, at least for audio
73 // objects. (Do not worry about video objects yet, JS programs do not create 76 // objects. (Do not worry about video objects yet, JS programs do not create
(...skipping 16 matching lines...) Expand all
90 // Also our timers are not very accurate (especially for ogg), which becomes 93 // Also our timers are not very accurate (especially for ogg), which becomes
91 // evident at low speeds and on Vista. Since other speeds are risky and outside 94 // evident at low speeds and on Vista. Since other speeds are risky and outside
92 // the norms, we think 1/16x to 16x is a safe and useful range for now. 95 // the norms, we think 1/16x to 16x is a safe and useful range for now.
93 const double kMinRate = 0.0625; 96 const double kMinRate = 0.0625;
94 const double kMaxRate = 16.0; 97 const double kMaxRate = 16.0;
95 98
96 // Prefix for histograms related to Encrypted Media Extensions. 99 // Prefix for histograms related to Encrypted Media Extensions.
97 const char* kMediaEme = "Media.EME."; 100 const char* kMediaEme = "Media.EME.";
98 } // namespace 101 } // namespace
99 102
100 namespace webkit_media { 103 namespace content {
101 104
102 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ 105 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
103 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::CORSMode ## name) == \ 106 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::CORSMode ## name) == \
104 static_cast<int>(BufferedResourceLoader::k ## name), \ 107 static_cast<int>(BufferedResourceLoader::k ## name), \
105 mismatching_enums) 108 mismatching_enums)
106 COMPILE_ASSERT_MATCHING_ENUM(Unspecified); 109 COMPILE_ASSERT_MATCHING_ENUM(Unspecified);
107 COMPILE_ASSERT_MATCHING_ENUM(Anonymous); 110 COMPILE_ASSERT_MATCHING_ENUM(Anonymous);
108 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials); 111 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials);
109 #undef COMPILE_ASSERT_MATCHING_ENUM 112 #undef COMPILE_ASSERT_MATCHING_ENUM
110 113
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 379 }
377 380
378 void WebMediaPlayerImpl::setVolume(double volume) { 381 void WebMediaPlayerImpl::setVolume(double volume) {
379 DCHECK(main_loop_->BelongsToCurrentThread()); 382 DCHECK(main_loop_->BelongsToCurrentThread());
380 383
381 pipeline_->SetVolume(volume); 384 pipeline_->SetVolume(volume);
382 } 385 }
383 386
384 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ 387 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \
385 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \ 388 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \
386 static_cast<int>(webkit_media::chromium_name), \ 389 static_cast<int>(content::chromium_name), \
387 mismatching_enums) 390 mismatching_enums)
388 COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE); 391 COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE);
389 COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA); 392 COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA);
390 COMPILE_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO); 393 COMPILE_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO);
391 #undef COMPILE_ASSERT_MATCHING_ENUM 394 #undef COMPILE_ASSERT_MATCHING_ENUM
392 395
393 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { 396 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) {
394 DCHECK(main_loop_->BelongsToCurrentThread()); 397 DCHECK(main_loop_->BelongsToCurrentThread());
395 398
396 if (data_source_) 399 if (data_source_)
397 data_source_->SetPreload(static_cast<webkit_media::Preload>(preload)); 400 data_source_->SetPreload(static_cast<content::Preload>(preload));
398 } 401 }
399 402
400 bool WebMediaPlayerImpl::hasVideo() const { 403 bool WebMediaPlayerImpl::hasVideo() const {
401 DCHECK(main_loop_->BelongsToCurrentThread()); 404 DCHECK(main_loop_->BelongsToCurrentThread());
402 405
403 return pipeline_->HasVideo(); 406 return pipeline_->HasVideo();
404 } 407 }
405 408
406 bool WebMediaPlayerImpl::hasAudio() const { 409 bool WebMediaPlayerImpl::hasAudio() const {
407 DCHECK(main_loop_->BelongsToCurrentThread()); 410 DCHECK(main_loop_->BelongsToCurrentThread());
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 current_frame_ = frame; 1219 current_frame_ = frame;
1217 1220
1218 if (pending_repaint_) 1221 if (pending_repaint_)
1219 return; 1222 return;
1220 1223
1221 pending_repaint_ = true; 1224 pending_repaint_ = true;
1222 main_loop_->PostTask(FROM_HERE, base::Bind( 1225 main_loop_->PostTask(FROM_HERE, base::Bind(
1223 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1226 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1224 } 1227 }
1225 1228
1226 } // namespace webkit_media 1229 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698