OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ppapi/proxy/media_stream_video_track_resource.h" | 5 #include "ppapi/proxy/media_stream_video_track_resource.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/proxy/ppapi_messages.h" | 8 #include "ppapi/proxy/ppapi_messages.h" |
9 #include "ppapi/proxy/video_frame_resource.h" | 9 #include "ppapi/proxy/video_frame_resource.h" |
10 #include "ppapi/shared_impl/media_stream_buffer.h" | 10 #include "ppapi/shared_impl/media_stream_buffer.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 PP_Resource MediaStreamVideoTrackResource::GetVideoFrame() { | 184 PP_Resource MediaStreamVideoTrackResource::GetVideoFrame() { |
185 int32_t index = buffer_manager()->DequeueBuffer(); | 185 int32_t index = buffer_manager()->DequeueBuffer(); |
186 if (index < 0) | 186 if (index < 0) |
187 return 0; | 187 return 0; |
188 | 188 |
189 MediaStreamBuffer* buffer = buffer_manager()->GetBufferPointer(index); | 189 MediaStreamBuffer* buffer = buffer_manager()->GetBufferPointer(index); |
190 DCHECK(buffer); | 190 DCHECK(buffer); |
191 scoped_refptr<VideoFrameResource> resource = | 191 scoped_refptr<VideoFrameResource> resource = |
192 new VideoFrameResource(pp_instance(), index, buffer); | 192 new VideoFrameResource(pp_instance(), index, buffer); |
193 // Add |pp_resource()| and |resource| into |frames_|. | 193 // Add |pp_resource()| and |resource| into |frames_|. |
194 // |frames_| uses scoped_ptr<> to hold a ref of |resource|. It keeps the | 194 // |frames_| uses std::unique_ptr<> to hold a ref of |resource|. It keeps the |
195 // resource alive. | 195 // resource alive. |
196 frames_.insert(FrameMap::value_type(resource->pp_resource(), resource)); | 196 frames_.insert(FrameMap::value_type(resource->pp_resource(), resource)); |
197 return resource->GetReference(); | 197 return resource->GetReference(); |
198 } | 198 } |
199 | 199 |
200 void MediaStreamVideoTrackResource::ReleaseFrames() { | 200 void MediaStreamVideoTrackResource::ReleaseFrames() { |
201 for (FrameMap::iterator it = frames_.begin(); it != frames_.end(); ++it) { | 201 for (FrameMap::iterator it = frames_.begin(); it != frames_.end(); ++it) { |
202 // Just invalidate and release VideoFrameResorce, but keep PP_Resource. | 202 // Just invalidate and release VideoFrameResorce, but keep PP_Resource. |
203 // So plugin can still use |RecycleFrame()|. | 203 // So plugin can still use |RecycleFrame()|. |
204 it->second->Invalidate(); | 204 it->second->Invalidate(); |
(...skipping 11 matching lines...) Expand all Loading... |
216 } | 216 } |
217 if (TrackedCallback::IsPending(configure_callback_)) { | 217 if (TrackedCallback::IsPending(configure_callback_)) { |
218 scoped_refptr<TrackedCallback> callback; | 218 scoped_refptr<TrackedCallback> callback; |
219 callback.swap(configure_callback_); | 219 callback.swap(configure_callback_); |
220 callback->Run(params.result()); | 220 callback->Run(params.result()); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 } // namespace proxy | 224 } // namespace proxy |
225 } // namespace ppapi | 225 } // namespace ppapi |
OLD | NEW |