| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 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 23 matching lines...) Expand all Loading... |
| 34 #include "webrtc/common_video/rotation.h" | 34 #include "webrtc/common_video/rotation.h" |
| 35 | 35 |
| 36 namespace cricket { | 36 namespace cricket { |
| 37 | 37 |
| 38 // Represents a YUV420 (a.k.a. I420) video frame. | 38 // Represents a YUV420 (a.k.a. I420) video frame. |
| 39 class VideoFrame { | 39 class VideoFrame { |
| 40 public: | 40 public: |
| 41 VideoFrame() {} | 41 VideoFrame() {} |
| 42 virtual ~VideoFrame() {} | 42 virtual ~VideoFrame() {} |
| 43 | 43 |
| 44 virtual bool InitToBlack(int w, int h, int64_t time_stamp) = 0; | 44 virtual bool InitToBlack(int w, int h, size_t pixel_width, |
| 45 size_t pixel_height, int64_t time_stamp) = 0; |
| 45 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|. | 46 // Creates a frame from a raw sample with FourCC |format| and size |w| x |h|. |
| 46 // |h| can be negative indicating a vertically flipped image. | 47 // |h| can be negative indicating a vertically flipped image. |
| 47 // |dw| is destination width; can be less than |w| if cropping is desired. | 48 // |dw| is destination width; can be less than |w| if cropping is desired. |
| 48 // |dh| is destination height, like |dw|, but must be a positive number. | 49 // |dh| is destination height, like |dw|, but must be a positive number. |
| 49 // Returns whether the function succeeded or failed. | 50 // Returns whether the function succeeded or failed. |
| 50 | 51 |
| 51 virtual bool Reset(uint32_t fourcc, | 52 virtual bool Reset(uint32_t fourcc, |
| 52 int w, | 53 int w, |
| 53 int h, | 54 int h, |
| 54 int dw, | 55 int dw, |
| 55 int dh, | 56 int dh, |
| 56 uint8_t* sample, | 57 uint8_t* sample, |
| 57 size_t sample_size, | 58 size_t sample_size, |
| 59 size_t pixel_width, |
| 60 size_t pixel_height, |
| 58 int64_t time_stamp, | 61 int64_t time_stamp, |
| 59 webrtc::VideoRotation rotation, | 62 webrtc::VideoRotation rotation, |
| 60 bool apply_rotation) = 0; | 63 bool apply_rotation) = 0; |
| 61 | 64 |
| 62 // Basic accessors. | 65 // Basic accessors. |
| 63 // Note this is the width and height without rotation applied. | 66 // Note this is the width and height without rotation applied. |
| 64 virtual size_t GetWidth() const = 0; | 67 virtual size_t GetWidth() const = 0; |
| 65 virtual size_t GetHeight() const = 0; | 68 virtual size_t GetHeight() const = 0; |
| 66 | 69 |
| 67 size_t GetChromaWidth() const { return (GetWidth() + 1) / 2; } | 70 size_t GetChromaWidth() const { return (GetWidth() + 1) / 2; } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 // Returns the handle of the underlying video frame. This is used when the | 85 // Returns the handle of the underlying video frame. This is used when the |
| 83 // frame is backed by a texture. The object should be destroyed when it is no | 86 // frame is backed by a texture. The object should be destroyed when it is no |
| 84 // longer in use, so the underlying resource can be freed. | 87 // longer in use, so the underlying resource can be freed. |
| 85 virtual void* GetNativeHandle() const = 0; | 88 virtual void* GetNativeHandle() const = 0; |
| 86 | 89 |
| 87 // Returns the underlying video frame buffer. This function is ok to call | 90 // Returns the underlying video frame buffer. This function is ok to call |
| 88 // multiple times, but the returned object will refer to the same memory. | 91 // multiple times, but the returned object will refer to the same memory. |
| 89 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() | 92 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() |
| 90 const = 0; | 93 const = 0; |
| 91 | 94 |
| 95 // For retrieving the aspect ratio of each pixel. Usually this is 1x1, but |
| 96 // the aspect_ratio_idc parameter of H.264 can specify non-square pixels. |
| 97 virtual size_t GetPixelWidth() const = 0; |
| 98 virtual size_t GetPixelHeight() const = 0; |
| 99 |
| 92 virtual int64_t GetTimeStamp() const = 0; | 100 virtual int64_t GetTimeStamp() const = 0; |
| 93 virtual void SetTimeStamp(int64_t time_stamp) = 0; | 101 virtual void SetTimeStamp(int64_t time_stamp) = 0; |
| 94 | 102 |
| 95 // Indicates the rotation angle in degrees. | 103 // Indicates the rotation angle in degrees. |
| 96 // TODO(guoweis): Remove this function, rename GetVideoRotation and remove the | 104 // TODO(guoweis): Remove this function, rename GetVideoRotation and remove the |
| 97 // skeleton implementation of GetRotation once chrome is updated. | 105 // skeleton implementation of GetRotation once chrome is updated. |
| 98 virtual int GetRotation() const { return GetVideoRotation(); } | 106 virtual int GetRotation() const { return GetVideoRotation(); } |
| 99 virtual webrtc::VideoRotation GetVideoRotation() const { | 107 virtual webrtc::VideoRotation GetVideoRotation() const { |
| 100 return webrtc::kVideoRotation_0; | 108 return webrtc::kVideoRotation_0; |
| 101 } | 109 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 const uint8_t* sample, | 202 const uint8_t* sample, |
| 195 size_t sample_size); | 203 size_t sample_size); |
| 196 | 204 |
| 197 // Size of an I420 image of given dimensions when stored as a frame buffer. | 205 // Size of an I420 image of given dimensions when stored as a frame buffer. |
| 198 static size_t SizeOf(size_t w, size_t h) { | 206 static size_t SizeOf(size_t w, size_t h) { |
| 199 return w * h + ((w + 1) / 2) * ((h + 1) / 2) * 2; | 207 return w * h + ((w + 1) / 2) * ((h + 1) / 2) * 2; |
| 200 } | 208 } |
| 201 | 209 |
| 202 protected: | 210 protected: |
| 203 // Creates an empty frame. | 211 // Creates an empty frame. |
| 204 virtual VideoFrame *CreateEmptyFrame(int w, int h, | 212 virtual VideoFrame *CreateEmptyFrame(int w, int h, size_t pixel_width, |
| 213 size_t pixel_height, |
| 205 int64_t time_stamp) const = 0; | 214 int64_t time_stamp) const = 0; |
| 206 virtual void SetRotation(webrtc::VideoRotation rotation) = 0; | 215 virtual void SetRotation(webrtc::VideoRotation rotation) = 0; |
| 207 }; | 216 }; |
| 208 | 217 |
| 209 } // namespace cricket | 218 } // namespace cricket |
| 210 | 219 |
| 211 #endif // TALK_MEDIA_BASE_VIDEOFRAME_H_ | 220 #endif // TALK_MEDIA_BASE_VIDEOFRAME_H_ |
| OLD | NEW |