| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual void TearDown() { | 37 virtual void TearDown() { |
| 38 // Explicitly disconnect the VideoCapturer before to avoid data races | 38 // Explicitly disconnect the VideoCapturer before to avoid data races |
| 39 // (frames delivered to VideoCapturerListener while it's being destructed). | 39 // (frames delivered to VideoCapturerListener while it's being destructed). |
| 40 capturer_->RemoveSink(listener_.get()); | 40 capturer_->RemoveSink(listener_.get()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 class VideoCapturerListener | 44 class VideoCapturerListener |
| 45 : public rtc::VideoSinkInterface<cricket::VideoFrame> { | 45 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
| 46 public: | 46 public: |
| 47 struct Stats { | 47 struct Stats { |
| 48 int captured_frames; | 48 int captured_frames; |
| 49 int dropped_frames; | 49 int dropped_frames; |
| 50 bool last_adapt_was_no_op; | 50 bool last_adapt_was_no_op; |
| 51 | 51 |
| 52 int cropped_width; | 52 int cropped_width; |
| 53 int cropped_height; | 53 int cropped_height; |
| 54 int out_width; | 54 int out_width; |
| 55 int out_height; | 55 int out_height; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 explicit VideoCapturerListener(VideoAdapter* adapter) | 58 explicit VideoCapturerListener(VideoAdapter* adapter) |
| 59 : video_adapter_(adapter), | 59 : video_adapter_(adapter), |
| 60 captured_frames_(0), | 60 captured_frames_(0), |
| 61 dropped_frames_(0), | 61 dropped_frames_(0), |
| 62 last_adapt_was_no_op_(false) { | 62 last_adapt_was_no_op_(false) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 void OnFrame(const cricket::VideoFrame& frame) { | 65 void OnFrame(const webrtc::VideoFrame& frame) { |
| 66 rtc::CritScope lock(&crit_); | 66 rtc::CritScope lock(&crit_); |
| 67 const int in_width = frame.width(); | 67 const int in_width = frame.width(); |
| 68 const int in_height = frame.height(); | 68 const int in_height = frame.height(); |
| 69 int cropped_width; | 69 int cropped_width; |
| 70 int cropped_height; | 70 int cropped_height; |
| 71 int out_width; | 71 int out_width; |
| 72 int out_height; | 72 int out_height; |
| 73 if (video_adapter_->AdaptFrameResolution( | 73 if (video_adapter_->AdaptFrameResolution( |
| 74 in_width, in_height, | 74 in_width, in_height, |
| 75 frame.timestamp_us() * rtc::kNumNanosecsPerMicrosec, | 75 frame.timestamp_us() * rtc::kNumNanosecsPerMicrosec, |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 945 |
| 946 // Instead of getting the exact aspect ratio with cropped resolution 640x360, | 946 // Instead of getting the exact aspect ratio with cropped resolution 640x360, |
| 947 // the resolution should be adjusted to get a perfect scale factor instead. | 947 // the resolution should be adjusted to get a perfect scale factor instead. |
| 948 EXPECT_EQ(640, cropped_width_); | 948 EXPECT_EQ(640, cropped_width_); |
| 949 EXPECT_EQ(368, cropped_height_); | 949 EXPECT_EQ(368, cropped_height_); |
| 950 EXPECT_EQ(120, out_width_); | 950 EXPECT_EQ(120, out_width_); |
| 951 EXPECT_EQ(69, out_height_); | 951 EXPECT_EQ(69, out_height_); |
| 952 } | 952 } |
| 953 | 953 |
| 954 } // namespace cricket | 954 } // namespace cricket |
| OLD | NEW |