3 * Copyright 2013 Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "talk/media/webrtc/webrtctexturevideoframe.h"
30 #include "talk/base/common.h"
31 #include "talk/base/logging.h"
32 #include "talk/base/stream.h"
34 #define UNIMPLEMENTED \
35 LOG(LS_ERROR) << "Call to unimplemented function "<< __FUNCTION__; \
40 WebRtcTextureVideoFrame::WebRtcTextureVideoFrame(
41 webrtc::NativeHandle* handle, int width, int height, int64 elapsed_time,
43 : handle_(handle), width_(width), height_(height),
44 elapsed_time_(elapsed_time), time_stamp_(time_stamp) {}
46 WebRtcTextureVideoFrame::~WebRtcTextureVideoFrame() {}
48 bool WebRtcTextureVideoFrame::InitToBlack(
49 int w, int h, size_t pixel_width, size_t pixel_height, int64 elapsed_time,
55 bool WebRtcTextureVideoFrame::Reset(
56 uint32 fourcc, int w, int h, int dw, int dh, uint8* sample,
57 size_t sample_size, size_t pixel_width, size_t pixel_height,
58 int64 elapsed_time, int64 time_stamp, int rotation) {
63 const uint8* WebRtcTextureVideoFrame::GetYPlane() const {
68 const uint8* WebRtcTextureVideoFrame::GetUPlane() const {
73 const uint8* WebRtcTextureVideoFrame::GetVPlane() const {
78 uint8* WebRtcTextureVideoFrame::GetYPlane() {
83 uint8* WebRtcTextureVideoFrame::GetUPlane() {
88 uint8* WebRtcTextureVideoFrame::GetVPlane() {
93 int32 WebRtcTextureVideoFrame::GetYPitch() const {
98 int32 WebRtcTextureVideoFrame::GetUPitch() const {
100 return (width_ + 1) / 2;
103 int32 WebRtcTextureVideoFrame::GetVPitch() const {
105 return (width_ + 1) / 2;
108 VideoFrame* WebRtcTextureVideoFrame::Copy() const {
109 return new WebRtcTextureVideoFrame(
110 handle_, width_, height_, elapsed_time_, time_stamp_);
113 bool WebRtcTextureVideoFrame::MakeExclusive() {
118 size_t WebRtcTextureVideoFrame::CopyToBuffer(uint8* buffer, size_t size) const {
123 size_t WebRtcTextureVideoFrame::ConvertToRgbBuffer(
124 uint32 to_fourcc, uint8* buffer, size_t size, int stride_rgb) const {
129 bool WebRtcTextureVideoFrame::CopyToPlanes(
130 uint8* dst_y, uint8* dst_u, uint8* dst_v, int32 dst_pitch_y,
131 int32 dst_pitch_u, int32 dst_pitch_v) const {
136 void WebRtcTextureVideoFrame::CopyToFrame(VideoFrame* dst) const {
140 talk_base::StreamResult WebRtcTextureVideoFrame::Write(
141 talk_base::StreamInterface* stream, int* error) {
143 return talk_base::SR_ERROR;
145 void WebRtcTextureVideoFrame::StretchToPlanes(
146 uint8* dst_y, uint8* dst_u, uint8* dst_v, int32 dst_pitch_y,
147 int32 dst_pitch_u, int32 dst_pitch_v, size_t width, size_t height,
148 bool interpolate, bool vert_crop) const {
152 size_t WebRtcTextureVideoFrame::StretchToBuffer(
153 size_t dst_width, size_t dst_height, uint8* dst_buffer, size_t size,
154 bool interpolate, bool vert_crop) const {
159 void WebRtcTextureVideoFrame::StretchToFrame(
160 VideoFrame* dst, bool interpolate, bool vert_crop) const {
164 VideoFrame* WebRtcTextureVideoFrame::Stretch(
165 size_t dst_width, size_t dst_height, bool interpolate,
166 bool vert_crop) const {
171 bool WebRtcTextureVideoFrame::SetToBlack() {
176 VideoFrame* WebRtcTextureVideoFrame::CreateEmptyFrame(
177 int w, int h, size_t pixel_width, size_t pixel_height, int64 elapsed_time,
178 int64 time_stamp) const {
183 } // namespace cricket