Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/talk/media/webrtc/webrtcvideoframe.h @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 5.5 KB
Line 
1/*
2 * libjingle
3 * Copyright 2011 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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.
15 *
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.
26 */
27
28#ifndef TALK_MEDIA_WEBRTCVIDEOFRAME_H_
29#define TALK_MEDIA_WEBRTCVIDEOFRAME_H_
30
31#include "talk/base/buffer.h"
32#include "talk/base/refcount.h"
33#include "talk/base/scoped_ref_ptr.h"
34#include "talk/media/base/videoframe.h"
35#include "webrtc/common_types.h"
36#include "webrtc/modules/interface/module_common_types.h"
37
38namespace cricket {
39
40struct CapturedFrame;
41
42class WebRtcVideoFrame : public VideoFrame {
43 public:
44  WebRtcVideoFrame();
45  ~WebRtcVideoFrame();
46
47  // Creates a frame from a raw sample with FourCC "format" and size "w" x "h".
48  // "h" can be negative indicating a vertically flipped image.
49  // "dh" is destination height if cropping is desired and is always positive.
50  // Returns "true" if successful.
51  bool Init(uint32 format, int w, int h, int dw, int dh, uint8* sample,
52            size_t sample_size, size_t pixel_width, size_t pixel_height,
53            int64 elapsed_time, int64 time_stamp, int rotation);
54
55  bool Init(const CapturedFrame* frame, int dw, int dh);
56
57  // Aliases this WebRtcVideoFrame to a CapturedFrame. |frame| must outlive
58  // this WebRtcVideoFrame.
59  bool Alias(const CapturedFrame* frame, int dw, int dh);
60
61  bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height,
62                   int64 elapsed_time, int64 time_stamp);
63
64  // Aliases this WebRtcVideoFrame to a memory buffer. |buffer| must outlive
65  // this WebRtcVideoFrame.
66  void Alias(uint8* buffer, size_t buffer_size, int w, int h,
67             size_t pixel_width, size_t pixel_height, int64 elapsed_time,
68             int64 time_stamp, int rotation);
69
70  bool AddWatermark();
71  webrtc::VideoFrame* frame();
72  const webrtc::VideoFrame* frame() const;
73
74  // From base class VideoFrame.
75  virtual bool Reset(uint32 format, int w, int h, int dw, int dh, uint8* sample,
76                     size_t sample_size, size_t pixel_width,
77                     size_t pixel_height, int64 elapsed_time, int64 time_stamp,
78                     int rotation);
79
80  virtual size_t GetWidth() const;
81  virtual size_t GetHeight() const;
82  virtual const uint8* GetYPlane() const;
83  virtual const uint8* GetUPlane() const;
84  virtual const uint8* GetVPlane() const;
85  virtual uint8* GetYPlane();
86  virtual uint8* GetUPlane();
87  virtual uint8* GetVPlane();
88  virtual int32 GetYPitch() const { return frame()->Width(); }
89  virtual int32 GetUPitch() const { return (frame()->Width() + 1) / 2; }
90  virtual int32 GetVPitch() const { return (frame()->Width() + 1) / 2; }
91  virtual void* GetNativeHandle() const { return NULL; }
92
93  virtual size_t GetPixelWidth() const { return pixel_width_; }
94  virtual size_t GetPixelHeight() const { return pixel_height_; }
95  virtual int64 GetElapsedTime() const { return elapsed_time_; }
96  virtual int64 GetTimeStamp() const { return time_stamp_; }
97  virtual void SetElapsedTime(int64 elapsed_time) {
98    elapsed_time_ = elapsed_time;
99  }
100  virtual void SetTimeStamp(int64 time_stamp) { time_stamp_ = time_stamp; }
101
102  virtual int GetRotation() const { return rotation_; }
103
104  virtual VideoFrame* Copy() const;
105  virtual bool MakeExclusive();
106  virtual size_t CopyToBuffer(uint8* buffer, size_t size) const;
107  virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer,
108                                    size_t size, int stride_rgb) const;
109
110 private:
111  class FrameBuffer;
112  typedef talk_base::RefCountedObject<FrameBuffer> RefCountedBuffer;
113
114  void Attach(RefCountedBuffer* video_buffer, size_t buffer_size, int w, int h,
115              size_t pixel_width, size_t pixel_height, int64 elapsed_time,
116              int64 time_stamp, int rotation);
117
118  virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width,
119                                       size_t pixel_height, int64 elapsed_time,
120                                       int64 time_stamp) const;
121  void InitToEmptyBuffer(int w, int h, size_t pixel_width, size_t pixel_height,
122                         int64 elapsed_time, int64 time_stamp);
123
124  talk_base::scoped_refptr<RefCountedBuffer> video_buffer_;
125  bool is_black_;
126  size_t pixel_width_;
127  size_t pixel_height_;
128  int64 elapsed_time_;
129  int64 time_stamp_;
130  int rotation_;
131};
132
133}  // namespace cricket
134
135#endif  // TALK_MEDIA_WEBRTCVIDEOFRAME_H_
Note: See TracBrowser for help on using the repository browser.