Index: ppapi/shared_impl/media_stream_frame_buffer.h |
diff --git a/ppapi/shared_impl/media_stream_frame_buffer.h b/ppapi/shared_impl/media_stream_frame_buffer.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..de03712a427a87e5866e504368ee0e1acd3839f6 |
--- /dev/null |
+++ b/ppapi/shared_impl/media_stream_frame_buffer.h |
@@ -0,0 +1,77 @@ |
+// 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. |
+ |
+#ifndef PPAPI_SHARED_IMPL_MEDIA_STREAM_FRAME_BUFFER_H_ |
+#define PPAPI_SHARED_IMPL_MEDIA_STREAM_FRAME_BUFFER_H_ |
+ |
+#include <deque> |
+#include <vector> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/shared_memory.h" |
+#include "ppapi/shared_impl/media_stream_frame.h" |
+#include "ppapi/shared_impl/ppapi_shared_export.h" |
+ |
+namespace ppapi { |
+ |
+class PPAPI_SHARED_EXPORT MediaStreamFrameBuffer { |
+ public: |
+ class Delegate { |
+ public: |
+ // It is called when a new frame is enqueued. |
+ virtual void OnNewFrameEnqueued(); |
+ }; |
+ |
+ explicit MediaStreamFrameBuffer(Delegate* delegate); |
+ |
+ virtual ~MediaStreamFrameBuffer(); |
+ |
+ int32_t number_of_frames() const { return number_of_frames_; } |
+ |
+ int32_t frame_size() const { return frame_size_; } |
+ |
+ // Initializes shared memory for frames transmission. |
+ bool SetFrames(int32_t number_of_frames, |
+ int32_t frame_size, |
+ scoped_ptr<base::SharedMemory> shm, |
+ bool enqueue_all_frames); |
+ |
+ // Dequeues a frame from |frame_queue_|. |
+ int32_t DequeueFrame(); |
+ |
+ // Puts a frame into |frame_queue_|. |
+ void EnqueueFrame(int32_t index); |
+ |
+ // Gets a frame address for the given index. |
+ MediaStreamFrame* GetFramePointer(int32_t index); |
+ |
+ virtual void OnNewFrameEnqueued(); |
+ |
+ private: |
+ Delegate* delegate_; |
+ // A queue of incoming frame indexes. |
+ // For the input side, they are empty frames which will be filled with data |
+ // and sent to the output side. |
+ // For the output side, they are received frames waiting for consuming. |
+ std::deque<int32_t> frame_queue_; |
+ |
+ // A vector of frame pointers. It is used for index to pointer converting. |
+ std::vector<MediaStreamFrame*> frames_; |
+ |
+ // The frame size in bytes. |
+ int32_t frame_size_; |
+ |
+ // The number of frames in the shared memory. |
+ int32_t number_of_frames_; |
+ |
+ // A memory block shared between renderer and plugin processes. |
+ scoped_ptr<base::SharedMemory> shm_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaStreamFrameBuffer); |
+}; |
+ |
+} // namespace ppapi |
+ |
+#endif // PPAPI_SHAERD_IMPL_MEDIA_STREAM_FRAME_BUFFER_H_ |