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

Unified Diff: ppapi/shared_impl/media_stream_frame_buffer.cc

Issue 128683003: [PPAPI] Implement media stream video track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video_track_impl_cl
Patch Set: Update Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/shared_impl/media_stream_frame_buffer.h ('k') | ppapi/thunk/ppb_video_frame_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/shared_impl/media_stream_frame_buffer.cc
diff --git a/ppapi/shared_impl/media_stream_frame_buffer.cc b/ppapi/shared_impl/media_stream_frame_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ea968715a7264c08acf98536466c49feb49b222b
--- /dev/null
+++ b/ppapi/shared_impl/media_stream_frame_buffer.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/shared_impl/media_stream_frame_buffer.h"
+
+#include "base/logging.h"
+#include "ppapi/c/pp_errors.h"
+
+namespace ppapi {
+
+MediaStreamFrameBuffer::Delegate::~Delegate() {}
+
+void MediaStreamFrameBuffer::Delegate::OnNewFrameEnqueued() {
+}
+
+MediaStreamFrameBuffer::MediaStreamFrameBuffer(Delegate* delegate)
+ : delegate_(delegate),
+ frame_size_(0),
+ number_of_frames_(0) {
+ DCHECK(delegate_);
+}
+
+MediaStreamFrameBuffer::~MediaStreamFrameBuffer() {
+}
+
+bool MediaStreamFrameBuffer::SetFrames(
+ int32_t number_of_frames,
+ int32_t frame_size,
+ scoped_ptr<base::SharedMemory> shm,
+ bool enqueue_all_frames) {
+ DCHECK(shm);
+ DCHECK(!shm_);
+ DCHECK_GT(number_of_frames, 0);
+ DCHECK_GT(frame_size, static_cast<int32_t>(sizeof(MediaStreamFrame::Header)));
+ DCHECK_EQ(frame_size & 0x3, 0);
+
+ number_of_frames_ = number_of_frames;
+ frame_size_ = frame_size;
+
+ int32_t size = number_of_frames_ * frame_size;
+ shm_ = shm.Pass();
+ if (!shm_->Map(size))
+ return false;
+
+ uint8_t* p = reinterpret_cast<uint8_t*>(shm_->memory());
+ for (int32_t i = 0; i < number_of_frames; ++i) {
+ if (enqueue_all_frames)
+ frame_queue_.push_back(i);
+ frames_.push_back(reinterpret_cast<MediaStreamFrame*>(p));
+ p += frame_size_;
+ }
+ return true;
+}
+
+int32_t MediaStreamFrameBuffer::DequeueFrame() {
+ if (frame_queue_.empty())
+ return PP_ERROR_FAILED;
+ int32_t frame = frame_queue_.front();
+ frame_queue_.pop_front();
+ return frame;
+}
+
+void MediaStreamFrameBuffer::EnqueueFrame(int32_t index) {
+ DCHECK_GE(index, 0);
+ DCHECK_LT(index, number_of_frames_);
+ frame_queue_.push_back(index);
+ delegate_->OnNewFrameEnqueued();
+}
+
+MediaStreamFrame* MediaStreamFrameBuffer::GetFramePointer(
+ int32_t index) {
+ DCHECK_GE(index, 0);
+ DCHECK_LT(index, number_of_frames_);
+ return frames_[index];
+}
+
+} // namespace ppapi
« no previous file with comments | « ppapi/shared_impl/media_stream_frame_buffer.h ('k') | ppapi/thunk/ppb_video_frame_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698