OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 captured_frame_.pixel_width = 1; | 50 captured_frame_.pixel_width = 1; |
51 captured_frame_.data = nullptr; | 51 captured_frame_.data = nullptr; |
52 captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; | 52 captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; |
53 captured_frame_.fourcc = static_cast<uint32_t>(cricket::FOURCC_ANY); | 53 captured_frame_.fourcc = static_cast<uint32_t>(cricket::FOURCC_ANY); |
54 } | 54 } |
55 | 55 |
56 void UpdateCapturedFrame( | 56 void UpdateCapturedFrame( |
57 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 57 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
58 int rotation, | 58 int rotation, |
59 int64_t time_stamp_in_ns) { | 59 int64_t time_stamp_in_ns) { |
| 60 RTC_DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || |
| 61 rotation == 270); |
60 buffer_ = buffer; | 62 buffer_ = buffer; |
61 captured_frame_.width = buffer->width(); | 63 captured_frame_.width = buffer->width(); |
62 captured_frame_.height = buffer->height(); | 64 captured_frame_.height = buffer->height(); |
63 captured_frame_.time_stamp = time_stamp_in_ns; | 65 captured_frame_.time_stamp = time_stamp_in_ns; |
64 captured_frame_.rotation = rotation; | 66 captured_frame_.rotation = static_cast<webrtc::VideoRotation>(rotation); |
65 } | 67 } |
66 | 68 |
67 void ClearCapturedFrame() { | 69 void ClearCapturedFrame() { |
68 buffer_ = nullptr; | 70 buffer_ = nullptr; |
69 captured_frame_.width = 0; | 71 captured_frame_.width = 0; |
70 captured_frame_.height = 0; | 72 captured_frame_.height = 0; |
71 captured_frame_.time_stamp = 0; | 73 captured_frame_.time_stamp = 0; |
72 } | 74 } |
73 | 75 |
74 const cricket::CapturedFrame* GetCapturedFrame() const { | 76 const cricket::CapturedFrame* GetCapturedFrame() const { |
75 return &captured_frame_; | 77 return &captured_frame_; |
76 } | 78 } |
77 | 79 |
78 cricket::VideoFrame* CreateAliasedFrame( | 80 cricket::VideoFrame* CreateAliasedFrame( |
79 const cricket::CapturedFrame* captured_frame, | 81 const cricket::CapturedFrame* captured_frame, |
80 int dst_width, | 82 int dst_width, |
81 int dst_height) const override { | 83 int dst_height) const override { |
82 // Check that captured_frame is actually our frame. | 84 // Check that captured_frame is actually our frame. |
83 RTC_CHECK(captured_frame == &captured_frame_); | 85 RTC_CHECK(captured_frame == &captured_frame_); |
84 RTC_CHECK(buffer_->native_handle() == nullptr); | 86 RTC_CHECK(buffer_->native_handle() == nullptr); |
85 | 87 |
86 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( | 88 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( |
87 ShallowCenterCrop(buffer_, dst_width, dst_height), | 89 ShallowCenterCrop(buffer_, dst_width, dst_height), |
88 captured_frame->time_stamp, captured_frame->GetRotation())); | 90 captured_frame->time_stamp, captured_frame->rotation)); |
89 // Caller takes ownership. | 91 // Caller takes ownership. |
90 // TODO(magjed): Change CreateAliasedFrame() to return a rtc::scoped_ptr. | 92 // TODO(magjed): Change CreateAliasedFrame() to return a rtc::scoped_ptr. |
91 return apply_rotation_ ? frame->GetCopyWithRotationApplied()->Copy() | 93 return apply_rotation_ ? frame->GetCopyWithRotationApplied()->Copy() |
92 : frame.release(); | 94 : frame.release(); |
93 } | 95 } |
94 | 96 |
95 cricket::VideoFrame* CreateAliasedFrame( | 97 cricket::VideoFrame* CreateAliasedFrame( |
96 const cricket::CapturedFrame* input_frame, | 98 const cricket::CapturedFrame* input_frame, |
97 int cropped_input_width, | 99 int cropped_input_width, |
98 int cropped_input_height, | 100 int cropped_input_height, |
99 int output_width, | 101 int output_width, |
100 int output_height) const override { | 102 int output_height) const override { |
101 if (buffer_->native_handle() != nullptr) { | 103 if (buffer_->native_handle() != nullptr) { |
102 // TODO(perkj): Implement CreateAliasedFrame properly for textures. | 104 // TODO(perkj): Implement CreateAliasedFrame properly for textures. |
103 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( | 105 rtc::scoped_ptr<cricket::VideoFrame> frame(new cricket::WebRtcVideoFrame( |
104 buffer_, input_frame->time_stamp, input_frame->GetRotation())); | 106 buffer_, input_frame->time_stamp, input_frame->rotation)); |
105 return frame.release(); | 107 return frame.release(); |
106 } | 108 } |
107 return VideoFrameFactory::CreateAliasedFrame(input_frame, | 109 return VideoFrameFactory::CreateAliasedFrame(input_frame, |
108 cropped_input_width, | 110 cropped_input_width, |
109 cropped_input_height, | 111 cropped_input_height, |
110 output_width, | 112 output_width, |
111 output_height); | 113 output_height); |
112 } | 114 } |
113 | 115 |
114 private: | 116 private: |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 233 |
232 bool AndroidVideoCapturer::GetBestCaptureFormat( | 234 bool AndroidVideoCapturer::GetBestCaptureFormat( |
233 const cricket::VideoFormat& desired, | 235 const cricket::VideoFormat& desired, |
234 cricket::VideoFormat* best_format) { | 236 cricket::VideoFormat* best_format) { |
235 // Delegate this choice to VideoCapturerAndroid.startCapture(). | 237 // Delegate this choice to VideoCapturerAndroid.startCapture(). |
236 *best_format = desired; | 238 *best_format = desired; |
237 return true; | 239 return true; |
238 } | 240 } |
239 | 241 |
240 } // namespace webrtc | 242 } // namespace webrtc |
OLD | NEW |