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 25 matching lines...) Expand all Loading... |
36 #include "webrtc/common_video/interface/video_frame_buffer.h" | 36 #include "webrtc/common_video/interface/video_frame_buffer.h" |
37 | 37 |
38 namespace cricket { | 38 namespace cricket { |
39 | 39 |
40 struct CapturedFrame; | 40 struct CapturedFrame; |
41 | 41 |
42 class WebRtcVideoFrame : public VideoFrame { | 42 class WebRtcVideoFrame : public VideoFrame { |
43 public: | 43 public: |
44 WebRtcVideoFrame(); | 44 WebRtcVideoFrame(); |
45 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 45 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
46 int64_t elapsed_time_ns, | |
47 int64_t time_stamp_ns, | 46 int64_t time_stamp_ns, |
48 webrtc::VideoRotation rotation); | 47 webrtc::VideoRotation rotation); |
49 | 48 |
50 // TODO(guoweis): Remove this when chrome code base is updated. | 49 // TODO(guoweis): Remove this when chrome code base is updated. |
51 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 50 WebRtcVideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
52 int64_t elapsed_time_ns, | 51 int64_t elapsed_time_ns, |
53 int64_t time_stamp_ns); | 52 int64_t time_stamp_ns); |
54 | 53 |
55 ~WebRtcVideoFrame(); | 54 ~WebRtcVideoFrame(); |
56 | 55 |
57 // 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". |
58 // "h" can be negative indicating a vertically flipped image. | 57 // "h" can be negative indicating a vertically flipped image. |
59 // "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. |
60 // Returns "true" if successful. | 59 // Returns "true" if successful. |
61 bool Init(uint32 format, | 60 bool Init(uint32 format, |
62 int w, | 61 int w, |
63 int h, | 62 int h, |
64 int dw, | 63 int dw, |
65 int dh, | 64 int dh, |
66 uint8* sample, | 65 uint8* sample, |
67 size_t sample_size, | 66 size_t sample_size, |
68 size_t pixel_width, | 67 size_t pixel_width, |
69 size_t pixel_height, | 68 size_t pixel_height, |
70 int64_t elapsed_time_ns, | |
71 int64_t time_stamp_ns, | 69 int64_t time_stamp_ns, |
72 webrtc::VideoRotation rotation); | 70 webrtc::VideoRotation rotation); |
73 | 71 |
74 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); |
75 | 73 |
76 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, |
77 int64_t elapsed_time_ns, int64_t time_stamp_ns); | 75 int64_t time_stamp_ns); |
| 76 |
| 77 // TODO(magjed): Remove once Chromium is updated. |
| 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); |
78 | 80 |
79 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, |
80 int64_t elapsed_time_ns, int64_t time_stamp_ns); | 82 int64_t time_stamp_ns); |
81 | 83 |
82 // From base class VideoFrame. | 84 // From base class VideoFrame. |
83 virtual bool Reset(uint32 format, | 85 virtual bool Reset(uint32 format, |
84 int w, | 86 int w, |
85 int h, | 87 int h, |
86 int dw, | 88 int dw, |
87 int dh, | 89 int dh, |
88 uint8* sample, | 90 uint8* sample, |
89 size_t sample_size, | 91 size_t sample_size, |
90 size_t pixel_width, | 92 size_t pixel_width, |
91 size_t pixel_height, | 93 size_t pixel_height, |
92 int64_t elapsed_time_ns, | |
93 int64_t time_stamp_ns, | 94 int64_t time_stamp_ns, |
94 webrtc::VideoRotation rotation, | 95 webrtc::VideoRotation rotation, |
95 bool apply_rotation); | 96 bool apply_rotation); |
96 | 97 |
97 virtual size_t GetWidth() const; | 98 virtual size_t GetWidth() const; |
98 virtual size_t GetHeight() const; | 99 virtual size_t GetHeight() const; |
99 virtual const uint8* GetYPlane() const; | 100 virtual const uint8* GetYPlane() const; |
100 virtual const uint8* GetUPlane() const; | 101 virtual const uint8* GetUPlane() const; |
101 virtual const uint8* GetVPlane() const; | 102 virtual const uint8* GetVPlane() const; |
102 virtual uint8* GetYPlane(); | 103 virtual uint8* GetYPlane(); |
103 virtual uint8* GetUPlane(); | 104 virtual uint8* GetUPlane(); |
104 virtual uint8* GetVPlane(); | 105 virtual uint8* GetVPlane(); |
105 virtual int32 GetYPitch() const; | 106 virtual int32 GetYPitch() const; |
106 virtual int32 GetUPitch() const; | 107 virtual int32 GetUPitch() const; |
107 virtual int32 GetVPitch() const; | 108 virtual int32 GetVPitch() const; |
108 virtual void* GetNativeHandle() const; | 109 virtual void* GetNativeHandle() const; |
109 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() | 110 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() |
110 const; | 111 const; |
111 | 112 |
112 virtual size_t GetPixelWidth() const { return pixel_width_; } | 113 virtual size_t GetPixelWidth() const { return pixel_width_; } |
113 virtual size_t GetPixelHeight() const { return pixel_height_; } | 114 virtual size_t GetPixelHeight() const { return pixel_height_; } |
114 virtual int64_t GetElapsedTime() const { return elapsed_time_ns_; } | |
115 virtual int64_t GetTimeStamp() const { return time_stamp_ns_; } | 115 virtual int64_t GetTimeStamp() const { return time_stamp_ns_; } |
116 virtual void SetElapsedTime(int64_t elapsed_time_ns) { | |
117 elapsed_time_ns_ = elapsed_time_ns; | |
118 } | |
119 virtual void SetTimeStamp(int64_t time_stamp_ns) { | 116 virtual void SetTimeStamp(int64_t time_stamp_ns) { |
120 time_stamp_ns_ = time_stamp_ns; | 117 time_stamp_ns_ = time_stamp_ns; |
121 } | 118 } |
122 | 119 |
123 virtual webrtc::VideoRotation GetVideoRotation() const { return rotation_; } | 120 virtual webrtc::VideoRotation GetVideoRotation() const { return rotation_; } |
124 | 121 |
125 virtual VideoFrame* Copy() const; | 122 virtual VideoFrame* Copy() const; |
126 virtual bool IsExclusive() const; | 123 virtual bool IsExclusive() const; |
127 virtual bool MakeExclusive(); | 124 virtual bool MakeExclusive(); |
128 virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, | 125 virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, |
129 size_t size, int stride_rgb) const; | 126 size_t size, int stride_rgb) const; |
130 | 127 |
131 const VideoFrame* GetCopyWithRotationApplied() const override; | 128 const VideoFrame* GetCopyWithRotationApplied() const override; |
132 | 129 |
133 protected: | 130 protected: |
134 void SetRotation(webrtc::VideoRotation rotation) override { | 131 void SetRotation(webrtc::VideoRotation rotation) override { |
135 rotation_ = rotation; | 132 rotation_ = rotation; |
136 } | 133 } |
137 | 134 |
138 private: | 135 private: |
139 virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width, | 136 virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width, |
140 size_t pixel_height, | 137 size_t pixel_height, |
141 int64_t elapsed_time_ns, | |
142 int64_t time_stamp_ns) const; | 138 int64_t time_stamp_ns) const; |
143 | 139 |
144 // An opaque reference counted handle that stores the pixel data. | 140 // An opaque reference counted handle that stores the pixel data. |
145 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 141 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
146 size_t pixel_width_; | 142 size_t pixel_width_; |
147 size_t pixel_height_; | 143 size_t pixel_height_; |
148 int64_t elapsed_time_ns_; | |
149 int64_t time_stamp_ns_; | 144 int64_t time_stamp_ns_; |
150 webrtc::VideoRotation rotation_; | 145 webrtc::VideoRotation rotation_; |
151 | 146 |
152 // This is mutable as the calculation is expensive but once calculated, it | 147 // This is mutable as the calculation is expensive but once calculated, it |
153 // remains const. | 148 // remains const. |
154 mutable rtc::scoped_ptr<VideoFrame> rotated_frame_; | 149 mutable rtc::scoped_ptr<VideoFrame> rotated_frame_; |
155 }; | 150 }; |
156 | 151 |
157 } // namespace cricket | 152 } // namespace cricket |
158 | 153 |
159 #endif // TALK_MEDIA_WEBRTCVIDEOFRAME_H_ | 154 #endif // TALK_MEDIA_WEBRTCVIDEOFRAME_H_ |
OLD | NEW |