| 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 "content/browser/android/content_video_view.h" | 5 #include "content/browser/android/content_video_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void ContentVideoView::OnExitFullscreen() { | 118 void ContentVideoView::OnExitFullscreen() { |
| 119 JNIEnv* env = AttachCurrentThread(); | 119 JNIEnv* env = AttachCurrentThread(); |
| 120 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 120 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
| 121 if (!content_video_view.is_null()) | 121 if (!content_video_view.is_null()) |
| 122 Java_ContentVideoView_onExitFullscreen(env, content_video_view.obj()); | 122 Java_ContentVideoView_onExitFullscreen(env, content_video_view.obj()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ContentVideoView::RecordFullscreenPlayback( | 125 void ContentVideoView::RecordFullscreenPlayback(JNIEnv*, |
| 126 JNIEnv*, jobject, bool is_portrait_video, bool is_orientation_portrait) { | 126 const JavaParamRef<jobject>&, |
| 127 bool is_portrait_video, |
| 128 bool is_orientation_portrait) { |
| 127 UMA_HISTOGRAM_BOOLEAN("MobileFullscreenVideo.OrientationPortrait", | 129 UMA_HISTOGRAM_BOOLEAN("MobileFullscreenVideo.OrientationPortrait", |
| 128 is_orientation_portrait); | 130 is_orientation_portrait); |
| 129 UMA_HISTOGRAM_BOOLEAN("MobileFullscreenVideo.VideoPortrait", | 131 UMA_HISTOGRAM_BOOLEAN("MobileFullscreenVideo.VideoPortrait", |
| 130 is_portrait_video); | 132 is_portrait_video); |
| 131 } | 133 } |
| 132 | 134 |
| 133 void ContentVideoView::RecordExitFullscreenPlayback( | 135 void ContentVideoView::RecordExitFullscreenPlayback( |
| 134 JNIEnv*, jobject, bool is_portrait_video, | 136 JNIEnv*, |
| 137 const JavaParamRef<jobject>&, |
| 138 bool is_portrait_video, |
| 135 long playback_duration_in_milliseconds_before_orientation_change, | 139 long playback_duration_in_milliseconds_before_orientation_change, |
| 136 long playback_duration_in_milliseconds_after_orientation_change) { | 140 long playback_duration_in_milliseconds_after_orientation_change) { |
| 137 bool orientation_changed = ( | 141 bool orientation_changed = ( |
| 138 playback_duration_in_milliseconds_after_orientation_change != 0); | 142 playback_duration_in_milliseconds_after_orientation_change != 0); |
| 139 if (is_portrait_video) { | 143 if (is_portrait_video) { |
| 140 UMA_HISTOGRAM_COUNTS( | 144 UMA_HISTOGRAM_COUNTS( |
| 141 "MobileFullscreenVideo.PortraitDuration", | 145 "MobileFullscreenVideo.PortraitDuration", |
| 142 playback_duration_in_milliseconds_before_orientation_change); | 146 playback_duration_in_milliseconds_before_orientation_change); |
| 143 UMA_HISTOGRAM_COUNTS( | 147 UMA_HISTOGRAM_COUNTS( |
| 144 "MobileFullscreenVideo.PortraitRotation", orientation_changed); | 148 "MobileFullscreenVideo.PortraitRotation", orientation_changed); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 165 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | 169 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); |
| 166 if (player && player->IsPlayerReady()) { | 170 if (player && player->IsPlayerReady()) { |
| 167 Java_ContentVideoView_onUpdateMediaMetadata( | 171 Java_ContentVideoView_onUpdateMediaMetadata( |
| 168 env, content_video_view.obj(), player->GetVideoWidth(), | 172 env, content_video_view.obj(), player->GetVideoWidth(), |
| 169 player->GetVideoHeight(), | 173 player->GetVideoHeight(), |
| 170 static_cast<int>(player->GetDuration().InMilliseconds()), | 174 static_cast<int>(player->GetDuration().InMilliseconds()), |
| 171 player->CanPause(),player->CanSeekForward(), player->CanSeekBackward()); | 175 player->CanPause(),player->CanSeekForward(), player->CanSeekBackward()); |
| 172 } | 176 } |
| 173 } | 177 } |
| 174 | 178 |
| 175 bool ContentVideoView::IsPlaying(JNIEnv*, jobject obj) { | 179 bool ContentVideoView::IsPlaying(JNIEnv*, const JavaParamRef<jobject>& obj) { |
| 176 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); | 180 media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer(); |
| 177 return player ? player->IsPlaying() : false; | 181 return player ? player->IsPlaying() : false; |
| 178 } | 182 } |
| 179 | 183 |
| 180 void ContentVideoView::ExitFullscreen( | 184 void ContentVideoView::ExitFullscreen(JNIEnv*, |
| 181 JNIEnv*, jobject, jboolean release_media_player) { | 185 const JavaParamRef<jobject>&, |
| 186 jboolean release_media_player) { |
| 182 j_content_video_view_.reset(); | 187 j_content_video_view_.reset(); |
| 183 manager_->ExitFullscreen(release_media_player); | 188 manager_->ExitFullscreen(release_media_player); |
| 184 } | 189 } |
| 185 | 190 |
| 186 void ContentVideoView::SetSurface(JNIEnv* env, jobject obj, | 191 void ContentVideoView::SetSurface(JNIEnv* env, |
| 187 jobject surface) { | 192 const JavaParamRef<jobject>& obj, |
| 193 const JavaParamRef<jobject>& surface) { |
| 188 manager_->SetVideoSurface( | 194 manager_->SetVideoSurface( |
| 189 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); | 195 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); |
| 190 } | 196 } |
| 191 | 197 |
| 192 void ContentVideoView::RequestMediaMetadata(JNIEnv* env, jobject obj) { | 198 void ContentVideoView::RequestMediaMetadata(JNIEnv* env, |
| 199 const JavaParamRef<jobject>& obj) { |
| 193 base::MessageLoop::current()->PostTask( | 200 base::MessageLoop::current()->PostTask( |
| 194 FROM_HERE, | 201 FROM_HERE, |
| 195 base::Bind(&ContentVideoView::UpdateMediaMetadata, | 202 base::Bind(&ContentVideoView::UpdateMediaMetadata, |
| 196 weak_factory_.GetWeakPtr())); | 203 weak_factory_.GetWeakPtr())); |
| 197 } | 204 } |
| 198 | 205 |
| 199 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { | 206 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { |
| 200 return j_content_video_view_.get(env); | 207 return j_content_video_view_.get(env); |
| 201 } | 208 } |
| 202 | 209 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 return JavaObjectWeakGlobalRef(env, nullptr); | 223 return JavaObjectWeakGlobalRef(env, nullptr); |
| 217 | 224 |
| 218 return JavaObjectWeakGlobalRef( | 225 return JavaObjectWeakGlobalRef( |
| 219 env, | 226 env, |
| 220 Java_ContentVideoView_createContentVideoView( | 227 Java_ContentVideoView_createContentVideoView( |
| 221 env, | 228 env, |
| 222 j_content_view_core.obj(), | 229 j_content_view_core.obj(), |
| 223 reinterpret_cast<intptr_t>(this)).obj()); | 230 reinterpret_cast<intptr_t>(this)).obj()); |
| 224 } | 231 } |
| 225 } // namespace content | 232 } // namespace content |
| OLD | NEW |