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..67f0d52eaf12781b06b483fce1530cd38100b41e |
--- /dev/null |
+++ b/ppapi/shared_impl/media_stream_frame_buffer.h |
@@ -0,0 +1,75 @@ |
+// 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(); |
+ }; |
dmichael (off chromium)
2014/01/09 21:06:47
It might be simpler to just use a base::Closure fo
Peng
2014/01/10 19:14:30
I tried. It does not simplify code too much. :(
H
|
+ |
+ explicit MediaStreamFrameBuffer(Delegate* delegate); |
dmichael (off chromium)
2014/01/09 21:06:47
(If you keep the Delegate class, comment about own
Peng
2014/01/10 19:14:30
Done.
|
+ |
+ ~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); |
+ |
+ private: |
+ Delegate* delegate_; |
+ // A queue of incoming frame indexes. |
dmichael (off chromium)
2014/01/09 21:06:47
Can you elaborate more? It's not obvious what "inc
Peng
2014/01/10 19:14:30
I added a class level document. Done
|
+ // 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_ |