Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: ppapi/proxy/media_stream_video_track_resource.cc

Issue 140783004: [PPAPI] Pepper MediaStream API audio track implementation and example. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/proxy/media_stream_audio_track_resource.cc ('k') | ppapi/proxy/plugin_var_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/video_frame_resource.h" 8 #include "ppapi/proxy/video_frame_resource.h"
9 #include "ppapi/shared_impl/media_stream_frame.h" 9 #include "ppapi/shared_impl/media_stream_frame.h"
10 #include "ppapi/shared_impl/var.h" 10 #include "ppapi/shared_impl/var.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 get_frame_callback_->PostAbort(); 100 get_frame_callback_->PostAbort();
101 get_frame_callback_ = NULL; 101 get_frame_callback_ = NULL;
102 get_frame_output_ = 0; 102 get_frame_output_ = 0;
103 } 103 }
104 104
105 ReleaseFrames(); 105 ReleaseFrames();
106 MediaStreamTrackResourceBase::CloseInternal(); 106 MediaStreamTrackResourceBase::CloseInternal();
107 } 107 }
108 108
109 void MediaStreamVideoTrackResource::OnNewFrameEnqueued() { 109 void MediaStreamVideoTrackResource::OnNewFrameEnqueued() {
110 if (TrackedCallback::IsPending(get_frame_callback_)) { 110 if (!TrackedCallback::IsPending(get_frame_callback_))
111 *get_frame_output_ = GetVideoFrame(); 111 return;
112 get_frame_output_ = NULL; 112
113 scoped_refptr<TrackedCallback> callback; 113 *get_frame_output_ = GetVideoFrame();
114 callback.swap(get_frame_callback_); 114 int32_t result = *get_frame_output_ ? PP_OK : PP_ERROR_FAILED;
115 callback->Run(PP_OK); 115 get_frame_output_ = NULL;
116 } 116 scoped_refptr<TrackedCallback> callback;
117 callback.swap(get_frame_callback_);
118 callback->Run(result);
117 } 119 }
118 120
119 PP_Resource MediaStreamVideoTrackResource::GetVideoFrame() { 121 PP_Resource MediaStreamVideoTrackResource::GetVideoFrame() {
120 int32_t index = frame_buffer()->DequeueFrame(); 122 int32_t index = frame_buffer()->DequeueFrame();
121 if (index < 0) 123 if (index < 0)
122 return 0; 124 return 0;
125
123 MediaStreamFrame* frame = frame_buffer()->GetFramePointer(index); 126 MediaStreamFrame* frame = frame_buffer()->GetFramePointer(index);
127 DCHECK(frame);
124 scoped_refptr<VideoFrameResource> resource = 128 scoped_refptr<VideoFrameResource> resource =
125 new VideoFrameResource(pp_instance(), index, frame); 129 new VideoFrameResource(pp_instance(), index, frame);
126 // Add |pp_resource()| and |resource| into |frames_|. 130 // Add |pp_resource()| and |resource| into |frames_|.
127 // |frames_| uses scoped_ptr<> to hold a ref of |resource|. It keeps the 131 // |frames_| uses scoped_ptr<> to hold a ref of |resource|. It keeps the
128 // resource alive. 132 // resource alive.
129 frames_.insert(FrameMap::value_type(resource->pp_resource(), resource)); 133 frames_.insert(FrameMap::value_type(resource->pp_resource(), resource));
130 return resource->GetReference(); 134 return resource->GetReference();
131 } 135 }
132 136
133 void MediaStreamVideoTrackResource::ReleaseFrames() { 137 void MediaStreamVideoTrackResource::ReleaseFrames() {
134 FrameMap::iterator it = frames_.begin(); 138 FrameMap::iterator it = frames_.begin();
135 while (it != frames_.end()) { 139 while (it != frames_.end()) {
136 // Just invalidate and release VideoFrameResorce, but keep PP_Resource. 140 // Just invalidate and release VideoFrameResorce, but keep PP_Resource.
137 // So plugin can still use |RecycleFrame()|. 141 // So plugin can still use |RecycleFrame()|.
138 it->second->Invalidate(); 142 it->second->Invalidate();
139 it->second = NULL; 143 it->second = NULL;
140 } 144 }
141 } 145 }
142 146
143 } // namespace proxy 147 } // namespace proxy
144 } // namespace ppapi 148 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/media_stream_audio_track_resource.cc ('k') | ppapi/proxy/plugin_var_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698