OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 50 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
51 int64_t elapsed_time_ns, | 51 int64_t elapsed_time_ns, |
52 int64_t time_stamp_ns); | 52 int64_t time_stamp_ns); |
53 | 53 |
54 ~WebRtcVideoFrame(); | 54 ~WebRtcVideoFrame(); |
55 | 55 |
56 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". | 56 // Creates a frame from a raw sample with FourCC "format" and size "w" x "h". |
57 // "h" can be negative indicating a vertically flipped image. | 57 // "h" can be negative indicating a vertically flipped image. |
58 // "dh" is destination height if cropping is desired and is always positive. | 58 // "dh" is destination height if cropping is desired and is always positive. |
59 // Returns "true" if successful. | 59 // Returns "true" if successful. |
60 bool Init(uint32 format, | 60 bool Init(uint32_t format, |
61 int w, | 61 int w, |
62 int h, | 62 int h, |
63 int dw, | 63 int dw, |
64 int dh, | 64 int dh, |
65 uint8* sample, | 65 uint8_t* sample, |
66 size_t sample_size, | 66 size_t sample_size, |
67 size_t pixel_width, | 67 size_t pixel_width, |
68 size_t pixel_height, | 68 size_t pixel_height, |
69 int64_t time_stamp_ns, | 69 int64_t time_stamp_ns, |
70 webrtc::VideoRotation rotation); | 70 webrtc::VideoRotation rotation); |
71 | 71 |
72 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); | 72 bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation); |
73 | 73 |
74 void InitToEmptyBuffer(int w, int h, size_t pixel_width, size_t pixel_height, | 74 void InitToEmptyBuffer(int w, int h, size_t pixel_width, size_t pixel_height, |
75 int64_t time_stamp_ns); | 75 int64_t time_stamp_ns); |
76 | 76 |
77 // TODO(magjed): Remove once Chromium is updated. | 77 // TODO(magjed): Remove once Chromium is updated. |
78 bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height, | 78 bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height, |
79 int64_t elapsed_time_ns, int64_t time_stamp_ns); | 79 int64_t elapsed_time_ns, int64_t time_stamp_ns); |
80 | 80 |
81 bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height, | 81 bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height, |
82 int64_t time_stamp_ns); | 82 int64_t time_stamp_ns); |
83 | 83 |
84 // From base class VideoFrame. | 84 // From base class VideoFrame. |
85 virtual bool Reset(uint32 format, | 85 virtual bool Reset(uint32_t format, |
86 int w, | 86 int w, |
87 int h, | 87 int h, |
88 int dw, | 88 int dw, |
89 int dh, | 89 int dh, |
90 uint8* sample, | 90 uint8_t* sample, |
91 size_t sample_size, | 91 size_t sample_size, |
92 size_t pixel_width, | 92 size_t pixel_width, |
93 size_t pixel_height, | 93 size_t pixel_height, |
94 int64_t time_stamp_ns, | 94 int64_t time_stamp_ns, |
95 webrtc::VideoRotation rotation, | 95 webrtc::VideoRotation rotation, |
96 bool apply_rotation); | 96 bool apply_rotation); |
97 | 97 |
98 virtual size_t GetWidth() const; | 98 virtual size_t GetWidth() const; |
99 virtual size_t GetHeight() const; | 99 virtual size_t GetHeight() const; |
100 virtual const uint8* GetYPlane() const; | 100 virtual const uint8_t* GetYPlane() const; |
101 virtual const uint8* GetUPlane() const; | 101 virtual const uint8_t* GetUPlane() const; |
102 virtual const uint8* GetVPlane() const; | 102 virtual const uint8_t* GetVPlane() const; |
103 virtual uint8* GetYPlane(); | 103 virtual uint8_t* GetYPlane(); |
104 virtual uint8* GetUPlane(); | 104 virtual uint8_t* GetUPlane(); |
105 virtual uint8* GetVPlane(); | 105 virtual uint8_t* GetVPlane(); |
106 virtual int32 GetYPitch() const; | 106 virtual int32_t GetYPitch() const; |
107 virtual int32 GetUPitch() const; | 107 virtual int32_t GetUPitch() const; |
108 virtual int32 GetVPitch() const; | 108 virtual int32_t GetVPitch() const; |
109 virtual void* GetNativeHandle() const; | 109 virtual void* GetNativeHandle() const; |
110 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() | 110 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() |
111 const; | 111 const; |
112 | 112 |
113 virtual size_t GetPixelWidth() const { return pixel_width_; } | 113 virtual size_t GetPixelWidth() const { return pixel_width_; } |
114 virtual size_t GetPixelHeight() const { return pixel_height_; } | 114 virtual size_t GetPixelHeight() const { return pixel_height_; } |
115 virtual int64_t GetTimeStamp() const { return time_stamp_ns_; } | 115 virtual int64_t GetTimeStamp() const { return time_stamp_ns_; } |
116 virtual void SetTimeStamp(int64_t time_stamp_ns) { | 116 virtual void SetTimeStamp(int64_t time_stamp_ns) { |
117 time_stamp_ns_ = time_stamp_ns; | 117 time_stamp_ns_ = time_stamp_ns; |
118 } | 118 } |
119 | 119 |
120 virtual webrtc::VideoRotation GetVideoRotation() const { return rotation_; } | 120 virtual webrtc::VideoRotation GetVideoRotation() const { return rotation_; } |
121 | 121 |
122 virtual VideoFrame* Copy() const; | 122 virtual VideoFrame* Copy() const; |
123 virtual bool IsExclusive() const; | 123 virtual bool IsExclusive() const; |
124 virtual bool MakeExclusive(); | 124 virtual bool MakeExclusive(); |
125 virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, | 125 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
126 size_t size, int stride_rgb) const; | 126 uint8_t* buffer, |
| 127 size_t size, |
| 128 int stride_rgb) const; |
127 | 129 |
128 const VideoFrame* GetCopyWithRotationApplied() const override; | 130 const VideoFrame* GetCopyWithRotationApplied() const override; |
129 | 131 |
130 protected: | 132 protected: |
131 void SetRotation(webrtc::VideoRotation rotation) override { | 133 void SetRotation(webrtc::VideoRotation rotation) override { |
132 rotation_ = rotation; | 134 rotation_ = rotation; |
133 } | 135 } |
134 | 136 |
135 private: | 137 private: |
136 virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width, | 138 virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width, |
137 size_t pixel_height, | 139 size_t pixel_height, |
138 int64_t time_stamp_ns) const; | 140 int64_t time_stamp_ns) const; |
139 | 141 |
140 // An opaque reference counted handle that stores the pixel data. | 142 // An opaque reference counted handle that stores the pixel data. |
141 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 143 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
142 size_t pixel_width_; | 144 size_t pixel_width_; |
143 size_t pixel_height_; | 145 size_t pixel_height_; |
144 int64_t time_stamp_ns_; | 146 int64_t time_stamp_ns_; |
145 webrtc::VideoRotation rotation_; | 147 webrtc::VideoRotation rotation_; |
146 | 148 |
147 // This is mutable as the calculation is expensive but once calculated, it | 149 // This is mutable as the calculation is expensive but once calculated, it |
148 // remains const. | 150 // remains const. |
149 mutable rtc::scoped_ptr<VideoFrame> rotated_frame_; | 151 mutable rtc::scoped_ptr<VideoFrame> rotated_frame_; |
150 }; | 152 }; |
151 | 153 |
152 } // namespace cricket | 154 } // namespace cricket |
153 | 155 |
154 #endif // TALK_MEDIA_WEBRTCVIDEOFRAME_H_ | 156 #endif // TALK_MEDIA_WEBRTCVIDEOFRAME_H_ |
OLD | NEW |