| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/video_frame.h" | 5 #include "media/base/video_frame.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/base/video_util.h" | 8 #include "media/base/video_util.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 default: | 42 default: |
| 43 NOTREACHED(); | 43 NOTREACHED(); |
| 44 return NULL; | 44 return NULL; |
| 45 } | 45 } |
| 46 return frame; | 46 return frame; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( | 50 scoped_refptr<VideoFrame> VideoFrame::WrapNativeTexture( |
| 51 uint32 texture_id, | 51 uint32 texture_id, |
| 52 uint32 texture_target, |
| 52 size_t width, | 53 size_t width, |
| 53 size_t height, | 54 size_t height, |
| 54 base::TimeDelta timestamp, | 55 base::TimeDelta timestamp, |
| 55 base::TimeDelta duration, | 56 base::TimeDelta duration, |
| 56 const base::Closure& no_longer_needed) { | 57 const base::Closure& no_longer_needed) { |
| 57 scoped_refptr<VideoFrame> frame( | 58 scoped_refptr<VideoFrame> frame( |
| 58 new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration)); | 59 new VideoFrame(NATIVE_TEXTURE, width, height, timestamp, duration)); |
| 59 frame->texture_id_ = texture_id; | 60 frame->texture_id_ = texture_id; |
| 61 frame->texture_target_ = texture_target; |
| 60 frame->texture_no_longer_needed_ = no_longer_needed; | 62 frame->texture_no_longer_needed_ = no_longer_needed; |
| 61 return frame; | 63 return frame; |
| 62 } | 64 } |
| 63 | 65 |
| 64 // static | 66 // static |
| 65 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { | 67 scoped_refptr<VideoFrame> VideoFrame::CreateEmptyFrame() { |
| 66 return new VideoFrame( | 68 return new VideoFrame( |
| 67 VideoFrame::EMPTY, 0, 0, base::TimeDelta(), base::TimeDelta()); | 69 VideoFrame::EMPTY, 0, 0, base::TimeDelta(), base::TimeDelta()); |
| 68 } | 70 } |
| 69 | 71 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 133 } |
| 132 | 134 |
| 133 VideoFrame::VideoFrame(VideoFrame::Format format, | 135 VideoFrame::VideoFrame(VideoFrame::Format format, |
| 134 size_t width, | 136 size_t width, |
| 135 size_t height, | 137 size_t height, |
| 136 base::TimeDelta timestamp, | 138 base::TimeDelta timestamp, |
| 137 base::TimeDelta duration) | 139 base::TimeDelta duration) |
| 138 : format_(format), | 140 : format_(format), |
| 139 width_(width), | 141 width_(width), |
| 140 height_(height), | 142 height_(height), |
| 141 texture_id_(0) { | 143 texture_id_(0), |
| 144 texture_target_(0) { |
| 142 SetTimestamp(timestamp); | 145 SetTimestamp(timestamp); |
| 143 SetDuration(duration); | 146 SetDuration(duration); |
| 144 memset(&strides_, 0, sizeof(strides_)); | 147 memset(&strides_, 0, sizeof(strides_)); |
| 145 memset(&data_, 0, sizeof(data_)); | 148 memset(&data_, 0, sizeof(data_)); |
| 146 } | 149 } |
| 147 | 150 |
| 148 VideoFrame::~VideoFrame() { | 151 VideoFrame::~VideoFrame() { |
| 149 if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) { | 152 if (format_ == NATIVE_TEXTURE && !texture_no_longer_needed_.is_null()) { |
| 150 texture_no_longer_needed_.Run(); | 153 texture_no_longer_needed_.Run(); |
| 151 texture_no_longer_needed_.Reset(); | 154 texture_no_longer_needed_.Reset(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 uint8* VideoFrame::data(size_t plane) const { | 244 uint8* VideoFrame::data(size_t plane) const { |
| 242 DCHECK(IsValidPlane(plane)); | 245 DCHECK(IsValidPlane(plane)); |
| 243 return data_[plane]; | 246 return data_[plane]; |
| 244 } | 247 } |
| 245 | 248 |
| 246 uint32 VideoFrame::texture_id() const { | 249 uint32 VideoFrame::texture_id() const { |
| 247 DCHECK_EQ(format_, NATIVE_TEXTURE); | 250 DCHECK_EQ(format_, NATIVE_TEXTURE); |
| 248 return texture_id_; | 251 return texture_id_; |
| 249 } | 252 } |
| 250 | 253 |
| 254 uint32 VideoFrame::texture_target() const { |
| 255 DCHECK_EQ(format_, NATIVE_TEXTURE); |
| 256 return texture_target_; |
| 257 } |
| 258 |
| 251 bool VideoFrame::IsEndOfStream() const { | 259 bool VideoFrame::IsEndOfStream() const { |
| 252 return format_ == VideoFrame::EMPTY; | 260 return format_ == VideoFrame::EMPTY; |
| 253 } | 261 } |
| 254 | 262 |
| 255 } // namespace media | 263 } // namespace media |
| OLD | NEW |