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