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

Side by Side Diff: remoting/codec/video_encoder_vp8_unittest.cc

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: q Created 7 years, 8 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 (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 "remoting/codec/video_encoder_vp8.h" 5 #include "remoting/codec/video_encoder_vp8.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "media/video/capture/screen/screen_capture_data.h"
14 #include "remoting/codec/codec_test.h" 13 #include "remoting/codec/codec_test.h"
15 #include "remoting/proto/video.pb.h" 14 #include "remoting/proto/video.pb.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
17 17
18 namespace { 18 namespace {
19 19
20 const int kIntMax = std::numeric_limits<int>::max(); 20 const int kIntMax = std::numeric_limits<int>::max();
21 21
22 } // namespace 22 } // namespace
23 23
24 namespace remoting { 24 namespace remoting {
25 25
26 TEST(VideoEncoderVp8Test, TestVideoEncoder) { 26 TEST(VideoEncoderVp8Test, TestVideoEncoder) {
27 VideoEncoderVp8 encoder; 27 VideoEncoderVp8 encoder;
28 TestVideoEncoder(&encoder, false); 28 TestVideoEncoder(&encoder, false);
29 } 29 }
30 30
31 class VideoEncoderCallback { 31 class VideoEncoderCallback {
32 public: 32 public:
33 void DataAvailable(scoped_ptr<VideoPacket> packet) { 33 void DataAvailable(scoped_ptr<VideoPacket> packet) {
34 } 34 }
35 }; 35 };
36 36
37 // Test that calling Encode with a differently-sized media::ScreenCaptureData 37 // Test that calling Encode with a differently-sized media::ScreenCaptureData
38 // does not leak memory. 38 // does not leak memory.
39 TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) { 39 TEST(VideoEncoderVp8Test, TestSizeChangeNoLeak) {
40 int height = 1000; 40 int height = 1000;
41 int width = 1000; 41 int width = 1000;
42 const int kBytesPerPixel = 4;
43 42
44 VideoEncoderVp8 encoder; 43 VideoEncoderVp8 encoder;
45 VideoEncoderCallback callback; 44 VideoEncoderCallback callback;
46 45
47 std::vector<uint8> buffer(width * height * kBytesPerPixel); 46 scoped_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame(
48 scoped_refptr<media::ScreenCaptureData> capture_data( 47 webrtc::DesktopSize(width, height)));
49 new media::ScreenCaptureData(&buffer.front(), width * kBytesPerPixel, 48
50 SkISize::Make(width, height))); 49 encoder.Encode(frame.get(), base::Bind(&VideoEncoderCallback::DataAvailable,
alexeypa (please no reviews) 2013/04/26 21:33:58 nit: Looking at this get() I think the method shou
Sergey Ulanov 2013/05/07 22:25:50 it takes const pointer now
51 encoder.Encode(capture_data, false, 50 base::Unretained(&callback)));
52 base::Bind(&VideoEncoderCallback::DataAvailable,
53 base::Unretained(&callback)));
54 51
55 height /= 2; 52 height /= 2;
56 capture_data = new media::ScreenCaptureData( 53 frame.reset(new webrtc::BasicDesktopFrame(
57 &buffer.front(), width * kBytesPerPixel, SkISize::Make(width, height)); 54 webrtc::DesktopSize(width, height)));
58 encoder.Encode(capture_data, false, 55 encoder.Encode(frame.get(), base::Bind(&VideoEncoderCallback::DataAvailable,
59 base::Bind(&VideoEncoderCallback::DataAvailable, 56 base::Unretained(&callback)));
60 base::Unretained(&callback)));
61 } 57 }
62 58
63 class VideoEncoderDpiCallback { 59 class VideoEncoderDpiCallback {
64 public: 60 public:
65 void DataAvailable(scoped_ptr<VideoPacket> packet) { 61 void DataAvailable(scoped_ptr<VideoPacket> packet) {
66 EXPECT_EQ(packet->format().x_dpi(), 96); 62 EXPECT_EQ(packet->format().x_dpi(), 96);
67 EXPECT_EQ(packet->format().y_dpi(), 97); 63 EXPECT_EQ(packet->format().y_dpi(), 97);
68 } 64 }
69 }; 65 };
70 66
71 // Test that the DPI information is correctly propagated from the 67 // Test that the DPI information is correctly propagated from the
72 // media::ScreenCaptureData to the VideoPacket. 68 // media::ScreenCaptureData to the VideoPacket.
73 TEST(VideoEncoderVp8Test, TestDpiPropagation) { 69 TEST(VideoEncoderVp8Test, TestDpiPropagation) {
74 int height = 32; 70 int height = 32;
75 int width = 32; 71 int width = 32;
76 const int kBytesPerPixel = 4;
77 72
78 VideoEncoderVp8 encoder; 73 VideoEncoderVp8 encoder;
79 VideoEncoderDpiCallback callback; 74 VideoEncoderDpiCallback callback;
80 75
81 std::vector<uint8> buffer(width * height * kBytesPerPixel); 76 scoped_ptr<webrtc::DesktopFrame> frame(new webrtc::BasicDesktopFrame(
82 scoped_refptr<media::ScreenCaptureData> capture_data( 77 webrtc::DesktopSize(width, height)));
83 new media::ScreenCaptureData(&buffer.front(), width * kBytesPerPixel, 78 frame->set_dpi(webrtc::DesktopVector(96, 97));
84 SkISize::Make(width, height))); 79 encoder.Encode(frame.get(),
85 capture_data->set_dpi(SkIPoint::Make(96, 97));
86 encoder.Encode(capture_data, false,
87 base::Bind(&VideoEncoderDpiCallback::DataAvailable, 80 base::Bind(&VideoEncoderDpiCallback::DataAvailable,
88 base::Unretained(&callback))); 81 base::Unretained(&callback)));
89 } 82 }
90 83
91 } // namespace remoting 84 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698