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

Side by Side Diff: remoting/client/jni/chromoting_jni.cc

Issue 19297003: Add support for drawing video onto a Java ByteBuffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename to JniFrameConsumer, use WeakPtrFactory, eliminate buffer_ pointer 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 "remoting/client/jni/chromoting_jni.h" 5 #include "remoting/client/jni/chromoting_jni.h"
6 6
7 #include "base/android/base_jni_registrar.h" 7 #include "base/android/base_jni_registrar.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "media/base/yuv_convert.h"
10 #include "net/android/net_jni_registrar.h" 11 #include "net/android/net_jni_registrar.h"
11 #include "remoting/base/url_request_context.h" 12 #include "remoting/base/url_request_context.h"
12 #include "remoting/client/jni/chromoting_jni_instance.h"
13 13
14 namespace { 14 namespace {
15 // Class and package name of the Java class supporting the methods we call. 15 // Class and package name of the Java class supporting the methods we call.
16 const char* const JAVA_CLASS = "org/chromium/chromoting/jni/JNIInterface"; 16 const char* const JAVA_CLASS = "org/chromium/chromoting/jni/JNIInterface";
17 } // namespace 17 } // namespace
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 // static 21 // static
22 ChromotingJni* ChromotingJni::GetInstance() { 22 ChromotingJni* ChromotingJni::GetInstance() {
(...skipping 24 matching lines...) Expand all
47 base::MessageLoop::QuitClosure()); 47 base::MessageLoop::QuitClosure());
48 network_task_runner_ = AutoThread::CreateWithType("native_net", 48 network_task_runner_ = AutoThread::CreateWithType("native_net",
49 ui_task_runner_, 49 ui_task_runner_,
50 base::MessageLoop::TYPE_IO); 50 base::MessageLoop::TYPE_IO);
51 display_task_runner_ = AutoThread::Create("native_disp", 51 display_task_runner_ = AutoThread::Create("native_disp",
52 ui_task_runner_); 52 ui_task_runner_);
53 53
54 url_requester_ = new URLRequestContextGetter(ui_task_runner_, 54 url_requester_ = new URLRequestContextGetter(ui_task_runner_,
55 network_task_runner_); 55 network_task_runner_);
56 56
57 // Allows later decoding of video frames.
58 media::InitializeCPUSpecificYUVConversions();
59
57 class_ = static_cast<jclass>(env->NewGlobalRef(env->FindClass(JAVA_CLASS))); 60 class_ = static_cast<jclass>(env->NewGlobalRef(env->FindClass(JAVA_CLASS)));
58 } 61 }
59 62
60 ChromotingJni::~ChromotingJni() { 63 ChromotingJni::~ChromotingJni() {
61 // The singleton should only ever be destroyed on the main thread. 64 // The singleton should only ever be destroyed on the main thread.
62 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 65 DCHECK(ui_task_runner_->BelongsToCurrentThread());
63 66
64 // The session must be shut down first, since it depends on our other 67 // The session must be shut down first, since it depends on our other
65 // components' still being alive. 68 // components' still being alive.
66 DisconnectFromHost(); 69 DisconnectFromHost();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 110
108 void ChromotingJni::DisplayAuthenticationPrompt() { 111 void ChromotingJni::DisplayAuthenticationPrompt() {
109 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 112 DCHECK(ui_task_runner_->BelongsToCurrentThread());
110 113
111 JNIEnv* env = base::android::AttachCurrentThread(); 114 JNIEnv* env = base::android::AttachCurrentThread();
112 env->CallStaticVoidMethod( 115 env->CallStaticVoidMethod(
113 class_, 116 class_,
114 env->GetStaticMethodID(class_, "displayAuthenticationPrompt", "()V")); 117 env->GetStaticMethodID(class_, "displayAuthenticationPrompt", "()V"));
115 } 118 }
116 119
120 void ChromotingJni::UpdateImageBuffer(int width, int height, jobject buffer) {
121 DCHECK(display_task_runner_->BelongsToCurrentThread());
122
123 JNIEnv* env = base::android::AttachCurrentThread();
124 env->SetStaticIntField(
125 class_,
126 env->GetStaticFieldID(class_, "width", "I"),
127 width);
128 env->SetStaticIntField(
129 class_,
130 env->GetStaticFieldID(class_, "height", "I"),
131 height);
132 env->SetStaticObjectField(
133 class_,
134 env->GetStaticFieldID(class_, "buffer", "Ljava/nio/ByteBuffer;"),
135 buffer);
136 }
137
138 void ChromotingJni::RedrawCanvas() {
139 DCHECK(display_task_runner_->BelongsToCurrentThread());
140
141 JNIEnv* env = base::android::AttachCurrentThread();
142 env->CallStaticVoidMethod(
143 class_,
144 env->GetStaticMethodID(class_, "redrawGraphicsInternal", "()V"));
145 }
146
117 } // namespace remoting 147 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698