OLD | NEW |
---|---|
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 | 110 |
111 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ | 111 #define COMPILE_ASSERT_MATCHING_ENUM(name) \ |
112 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::CORSMode ## name) == \ | 112 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::CORSMode ## name) == \ |
113 static_cast<int>(BufferedResourceLoader::k ## name), \ | 113 static_cast<int>(BufferedResourceLoader::k ## name), \ |
114 mismatching_enums) | 114 mismatching_enums) |
115 COMPILE_ASSERT_MATCHING_ENUM(Unspecified); | 115 COMPILE_ASSERT_MATCHING_ENUM(Unspecified); |
116 COMPILE_ASSERT_MATCHING_ENUM(Anonymous); | 116 COMPILE_ASSERT_MATCHING_ENUM(Anonymous); |
117 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials); | 117 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials); |
118 #undef COMPILE_ASSERT_MATCHING_ENUM | 118 #undef COMPILE_ASSERT_MATCHING_ENUM |
119 | 119 |
120 template <class T> | |
Ami GONE FROM CHROMIUM
2014/01/09 01:57:07
That's some nice clevermeistering, but you can eve
scherkus (not reviewing)
2014/01/09 02:14:45
it feels like I'm practicing some form of dark sor
| |
121 static base::Callback<T> BindToRenderLoop( | |
122 const scoped_refptr<base::MessageLoopProxy>& render_loop, | |
123 const base::Callback<T>& cb) { | |
124 DCHECK(render_loop->BelongsToCurrentThread()); | |
125 return media::BindToCurrentLoop(cb); | |
126 } | |
127 | |
120 #define BIND_TO_RENDER_LOOP(function) \ | 128 #define BIND_TO_RENDER_LOOP(function) \ |
121 media::BindToLoop(main_loop_, base::Bind(function, AsWeakPtr())) | 129 BindToRenderLoop(main_loop_, base::Bind(function, AsWeakPtr())) |
122 | |
123 #define BIND_TO_RENDER_LOOP_1(function, arg1) \ | |
124 media::BindToLoop(main_loop_, base::Bind(function, AsWeakPtr(), arg1)) | |
125 | |
126 #define BIND_TO_RENDER_LOOP_2(function, arg1, arg2) \ | |
127 media::BindToLoop(main_loop_, base::Bind(function, AsWeakPtr(), arg1, arg2)) | |
128 | 130 |
129 static void LogMediaSourceError(const scoped_refptr<media::MediaLog>& media_log, | 131 static void LogMediaSourceError(const scoped_refptr<media::MediaLog>& media_log, |
130 const std::string& error) { | 132 const std::string& error) { |
131 media_log->AddEvent(media_log->CreateMediaSourceErrorEvent(error)); | 133 media_log->AddEvent(media_log->CreateMediaSourceErrorEvent(error)); |
132 } | 134 } |
133 | 135 |
134 WebMediaPlayerImpl::WebMediaPlayerImpl( | 136 WebMediaPlayerImpl::WebMediaPlayerImpl( |
135 content::RenderView* render_view, | 137 content::RenderView* render_view, |
136 blink::WebFrame* frame, | 138 blink::WebFrame* frame, |
137 blink::WebMediaPlayerClient* client, | 139 blink::WebMediaPlayerClient* client, |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 SetNetworkState(WebMediaPlayer::NetworkStateIdle); | 1070 SetNetworkState(WebMediaPlayer::NetworkStateIdle); |
1069 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) | 1071 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) |
1070 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 1072 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
1071 media_log_->AddEvent( | 1073 media_log_->AddEvent( |
1072 media_log_->CreateBooleanEvent( | 1074 media_log_->CreateBooleanEvent( |
1073 media::MediaLogEvent::NETWORK_ACTIVITY_SET, | 1075 media::MediaLogEvent::NETWORK_ACTIVITY_SET, |
1074 "is_downloading_data", is_downloading)); | 1076 "is_downloading_data", is_downloading)); |
1075 } | 1077 } |
1076 | 1078 |
1077 void WebMediaPlayerImpl::StartPipeline() { | 1079 void WebMediaPlayerImpl::StartPipeline() { |
1080 DCHECK(main_loop_->BelongsToCurrentThread()); | |
1078 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 1081 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
1079 | 1082 |
1080 // Keep track if this is a MSE or non-MSE playback. | 1083 // Keep track if this is a MSE or non-MSE playback. |
1081 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", | 1084 UMA_HISTOGRAM_BOOLEAN("Media.MSE.Playback", |
1082 (load_type_ == LoadTypeMediaSource)); | 1085 (load_type_ == LoadTypeMediaSource)); |
1083 | 1086 |
1084 // Figure out which demuxer to use. | 1087 // Figure out which demuxer to use. |
1085 if (load_type_ != LoadTypeMediaSource) { | 1088 if (load_type_ != LoadTypeMediaSource) { |
1086 DCHECK(!chunk_demuxer_); | 1089 DCHECK(!chunk_demuxer_); |
1087 DCHECK(data_source_); | 1090 DCHECK(data_source_); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 // The |current_frame_| wasn't painted, it is being replaced, and we haven't | 1305 // The |current_frame_| wasn't painted, it is being replaced, and we haven't |
1303 // even gotten the chance to request a repaint for it yet. Mark it as dropped. | 1306 // even gotten the chance to request a repaint for it yet. Mark it as dropped. |
1304 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); | 1307 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); |
1305 DVLOG(1) << "Frame dropped before being painted: " | 1308 DVLOG(1) << "Frame dropped before being painted: " |
1306 << current_frame_->GetTimestamp().InSecondsF(); | 1309 << current_frame_->GetTimestamp().InSecondsF(); |
1307 if (frames_dropped_before_paint_ < kuint32max) | 1310 if (frames_dropped_before_paint_ < kuint32max) |
1308 frames_dropped_before_paint_++; | 1311 frames_dropped_before_paint_++; |
1309 } | 1312 } |
1310 | 1313 |
1311 } // namespace content | 1314 } // namespace content |
OLD | NEW |