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

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

Issue 19297003: Add support for drawing video onto a Java ByteBuffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reword highly cryptic comment 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/client/jni/frame_consumer_impl.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/logging.h"
9 #include "media/base/yuv_convert.h"
10 #include "remoting/client/frame_producer.h"
11 #include "remoting/client/jni/chromoting_jni.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
13
14 namespace {
15
16 class DirectDesktopFrame : public webrtc::BasicDesktopFrame {
Wez 2013/07/16 02:18:12 What is "direct" about this? Wouldn't JniDesktopFr
solb 2013/07/16 18:00:57 A direct byte buffer (see line 31) is a region of
17 public:
18 DirectDesktopFrame(int width, int height);
19
20 jobject buffer() const {
21 return buffer_;
22 }
23
24 private:
25 jobject buffer_;
26 };
27
28 DirectDesktopFrame::DirectDesktopFrame(int width, int height)
29 : webrtc::BasicDesktopFrame(webrtc::DesktopSize(width, height)) {
30 JNIEnv* env = base::android::AttachCurrentThread();
31 buffer_ = env->NewDirectByteBuffer(data(), stride()*height);
32 }
33
34 } // namespace
35
36 namespace remoting {
37
38 FrameConsumerImpl::FrameConsumerImpl()
39 : frame_producer_(NULL),
40 buffer_(NULL) {
41 media::InitializeCPUSpecificYUVConversions();
Wez 2013/07/16 02:18:12 Isn't this intended as a one-off per-process initi
solb 2013/07/16 18:00:57 Done.
42 }
43
44 FrameConsumerImpl::~FrameConsumerImpl() {
45 ReturnBuffer(buffer_);
Wez 2013/07/16 02:18:12 This doesn't look right - surely the caller must h
solb 2013/07/16 18:00:57 Done.
46 }
47
48 void FrameConsumerImpl::set_frame_producer(FrameProducer* producer) {
49 frame_producer_ = producer;
50 }
51
52 void FrameConsumerImpl::ApplyBuffer(const SkISize& view_size,
53 const SkIRect& clip_area,
54 webrtc::DesktopFrame* buffer,
55 const SkRegion& region) {
56 ChromotingJni::GetInstance()->RedrawCanvas();
57 // Give |frame_producer_| back the same buffer so that |buffer| and |buffer_|
Wez 2013/07/16 02:18:12 Blank line before this comment, please.
solb 2013/07/16 18:00:57 Done.
58 // are always the same exact pointer.
Wez 2013/07/16 02:18:12 nit: Suggest "Return |buffer| to |frame_producer_|
solb 2013/07/16 18:00:57 Done.
59 frame_producer_->DrawBuffer(buffer);
60 }
61
62 void FrameConsumerImpl::ReturnBuffer(webrtc::DesktopFrame* buffer) {
63 delete buffer;
64 // |buffer_| is the same pointer as |buffer|, so we just invalidated it.
Wez 2013/07/16 02:18:12 Is that guaranteed by the FrameConsumer interface?
Wez 2013/07/16 02:18:12 nit: Blank line before this comment, please.
solb 2013/07/16 18:00:57 Done.
solb 2013/07/16 18:00:57 Done.
65 buffer_ = NULL;
66 }
67
68 void FrameConsumerImpl::SetSourceSize(const SkISize& source_size,
69 const SkIPoint& dpi) {
Wez 2013/07/16 02:18:12 Output buffer size isn't dependent on input buffer
solb 2013/07/16 18:00:57 I'm making ApplyBuffer() check that the buffer is
70 view_size_ = source_size;
71 clip_area_ = SkIRect::MakeSize(source_size);
Wez 2013/07/16 02:18:12 |clip_area_| is in output coordinates, so surely i
solb 2013/07/16 18:00:57 Done.
72 frame_producer_->SetOutputSizeAndClip(view_size_, clip_area_);
73
74 if (!buffer_)
75 buffer_ = new DirectDesktopFrame(source_size.width(),
76 source_size.height());
Wez 2013/07/16 02:18:12 This is creating a frame of the |source_size|, i.e
solb 2013/07/16 18:00:57 Done.
77
78 ChromotingJni::GetInstance()->UpdateImageBuffer(
79 source_size.width(),
80 source_size.height(),
81 static_cast<DirectDesktopFrame*>(buffer_)->buffer());
82 frame_producer_->DrawBuffer(buffer_);
83 }
84
85 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698