1f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org/* 2f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * libjingle 3f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * Copyright 2013 Google Inc. 4f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * 5f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * Redistribution and use in source and binary forms, with or without 6f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * modification, are permitted provided that the following conditions are met: 7f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * 8f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 9f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * this list of conditions and the following disclaimer. 10f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 11f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * this list of conditions and the following disclaimer in the documentation 12f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * and/or other materials provided with the distribution. 13f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * 3. The name of the author may not be used to endorse or promote products 14f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * derived from this software without specific prior written permission. 15f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * 16f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org */ 27f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 28f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org#ifndef TALK_MEDIA_WEBRTC_WEBRTCTEXTUREVIDEOFRAME_H_ 29f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org#define TALK_MEDIA_WEBRTC_WEBRTCTEXTUREVIDEOFRAME_H_ 30f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 31cf81adffe15fa8ea0f333432e41f6d504148f18abuildbot@webrtc.org#include "talk/media/base/videoframe.h" 322a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/refcount.h" 332a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org#include "webrtc/base/scoped_ref_ptr.h" 34f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org#include "webrtc/common_video/interface/native_handle.h" 35f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 36f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.orgnamespace cricket { 37f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 38f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org// A video frame backed by the texture via a native handle. 39f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.orgclass WebRtcTextureVideoFrame : public VideoFrame { 40f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org public: 41f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org WebRtcTextureVideoFrame(webrtc::NativeHandle* handle, int width, int height, 42f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int64 elapsed_time, int64 time_stamp); 43f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual ~WebRtcTextureVideoFrame(); 44f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 45f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org // From base class VideoFrame. 46f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual bool InitToBlack(int w, int h, size_t pixel_width, 47f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org size_t pixel_height, int64 elapsed_time, 48f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int64 time_stamp); 49f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual bool Reset(uint32 fourcc, int w, int h, int dw, int dh, uint8* sample, 50f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org size_t sample_size, size_t pixel_width, 51f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org size_t pixel_height, int64 elapsed_time, int64 time_stamp, 52f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int rotation); 53f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t GetWidth() const { return width_; } 54f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t GetHeight() const { return height_; } 55f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual const uint8* GetYPlane() const; 56f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual const uint8* GetUPlane() const; 57f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual const uint8* GetVPlane() const; 58f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual uint8* GetYPlane(); 59f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual uint8* GetUPlane(); 60f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual uint8* GetVPlane(); 61f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual int32 GetYPitch() const; 62f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual int32 GetUPitch() const; 63f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual int32 GetVPitch() const; 64f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t GetPixelWidth() const { return 1; } 65f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t GetPixelHeight() const { return 1; } 66f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual int64 GetElapsedTime() const { return elapsed_time_; } 67f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual int64 GetTimeStamp() const { return time_stamp_; } 68f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual void SetElapsedTime(int64 elapsed_time) { 69f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org elapsed_time_ = elapsed_time; 70f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org } 71f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual void SetTimeStamp(int64 time_stamp) { time_stamp_ = time_stamp; } 72f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual int GetRotation() const { return 0; } 73f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual VideoFrame* Copy() const; 74f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual bool MakeExclusive(); 75f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t CopyToBuffer(uint8* buffer, size_t size) const; 76f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, 77f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org size_t size, int stride_rgb) const; 78f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual void* GetNativeHandle() const { return handle_.get(); } 79f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 80f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual bool CopyToPlanes( 81f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org uint8* dst_y, uint8* dst_u, uint8* dst_v, 82f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v) const; 83f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual void CopyToFrame(VideoFrame* target) const; 842a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org virtual rtc::StreamResult Write(rtc::StreamInterface* stream, 85f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int* error); 86f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual void StretchToPlanes( 87f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org uint8* y, uint8* u, uint8* v, int32 pitchY, int32 pitchU, int32 pitchV, 88f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org size_t width, size_t height, bool interpolate, bool crop) const; 89f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual size_t StretchToBuffer(size_t w, size_t h, uint8* buffer, size_t size, 90f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org bool interpolate, bool crop) const; 91f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual void StretchToFrame(VideoFrame* target, bool interpolate, 92f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org bool crop) const; 93f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual VideoFrame* Stretch(size_t w, size_t h, bool interpolate, 94f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org bool crop) const; 95f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual bool SetToBlack(); 96f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 97f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org protected: 98f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width, 99f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org size_t pixel_height, int64 elapsed_time, 100f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int64 time_stamp) const; 101f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 102f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org private: 103f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org // The handle of the underlying video frame. 1042a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org rtc::scoped_refptr<webrtc::NativeHandle> handle_; 105f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int width_; 106f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int height_; 107f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int64 elapsed_time_; 108f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org int64 time_stamp_; 109f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org}; 110f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 111f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org} // namespace cricket 112f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org 113f99f1011aa4cd22bd86ba2e4f7d239ea1b766ec8wu@webrtc.org#endif // TALK_MEDIA_WEBRTC_WEBRTCTEXTUREVIDEOFRAME_H_ 114