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

Side by Side Diff: services/media/common/media_pipe_base.h

Issue 1694963002: Change who allocated the MediaPipe's shared buffer. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix android trybots Created 4 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 | « services/media/audio/audio_track_impl.cc ('k') | services/media/common/media_pipe_base.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef SERVICES_MEDIA_COMMON_MEDIA_PIPE_BASE_H_ 5 #ifndef SERVICES_MEDIA_COMMON_MEDIA_PIPE_BASE_H_
6 #define SERVICES_MEDIA_COMMON_MEDIA_PIPE_BASE_H_ 6 #define SERVICES_MEDIA_COMMON_MEDIA_PIPE_BASE_H_
7 7
8 #include <atomic> 8 #include <atomic>
9 #include <deque> 9 #include <deque>
10 #include <memory> 10 #include <memory>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 SendPacketCallback cbk_; 43 SendPacketCallback cbk_;
44 std::atomic<MediaPipe::SendResult> result_; 44 std::atomic<MediaPipe::SendResult> result_;
45 }; 45 };
46 using MediaPacketStatePtr = std::unique_ptr<MediaPacketState>; 46 using MediaPacketStatePtr = std::unique_ptr<MediaPacketState>;
47 47
48 // Default constructor and destructor 48 // Default constructor and destructor
49 MediaPipeBase(); 49 MediaPipeBase();
50 ~MediaPipeBase() override; 50 ~MediaPipeBase() override;
51 51
52 // Initialize the internal state of the pipe (allocate resources, etc..) 52 // Initialize the internal state of the pipe (allocate resources, etc..)
53 MojoResult Init(InterfaceRequest<MediaPipe> request, 53 MojoResult Init(InterfaceRequest<MediaPipe> request);
54 uint64_t shared_buffer_size);
55 54
56 bool IsInitialized() const; 55 bool IsInitialized() const;
57 void Reset(); 56 void Reset();
58 57
59 protected: 58 protected:
60 class MappedSharedBuffer { 59 class MappedSharedBuffer {
61 public: 60 public:
62 static MappedSharedBufferPtr Create(size_t size); 61 static MappedSharedBufferPtr Create(ScopedSharedBufferHandle handle,
62 uint64_t size);
63 ~MappedSharedBuffer(); 63 ~MappedSharedBuffer();
64 64
65 const ScopedSharedBufferHandle& handle() const { return handle_; } 65 const ScopedSharedBufferHandle& handle() const { return handle_; }
66 size_t size() const { return size_; } 66 uint64_t size() const { return size_; }
67 void* base() const { return base_; } 67 void* base() const { return base_; }
68 68
69 private: 69 private:
70 explicit MappedSharedBuffer(size_t size); 70 MappedSharedBuffer(ScopedSharedBufferHandle handle, size_t size);
71 71
72 ScopedSharedBufferHandle handle_; 72 ScopedSharedBufferHandle handle_;
73 size_t size_; 73 size_t size_;
74 void* base_ = nullptr; 74 void* base_ = nullptr;
75 }; 75 };
76 76
77 // Interface to be implemented by derived classes 77 // Interface to be implemented by derived classes
78 virtual void OnPacketReceived(MediaPacketStatePtr state) = 0; 78 virtual void OnPacketReceived(MediaPacketStatePtr state) = 0;
79 virtual bool OnFlushRequested(const FlushCallback& cbk) = 0; 79 virtual bool OnFlushRequested(const FlushCallback& cbk) = 0;
80 80
81 MappedSharedBufferPtr buffer_; 81 MappedSharedBufferPtr buffer_;
82 82
83 private: 83 private:
84 Binding<MediaPipe> binding_; 84 Binding<MediaPipe> binding_;
85 85
86 // MediaPipe.mojom implementation. 86 // MediaPipe.mojom implementation.
87 void GetState(const GetStateCallback& cbk) final; 87 void SetBuffer(ScopedSharedBufferHandle handle, uint64_t size) final;
88 void SendPacket(MediaPacketPtr packet, 88 void SendPacket(MediaPacketPtr packet,
89 const SendPacketCallback& cbk) final; 89 const SendPacketCallback& cbk) final;
90 void Flush(const FlushCallback& cbk) final; 90 void Flush(const FlushCallback& cbk) final;
91 }; 91 };
92 92
93 } // namespace media 93 } // namespace media
94 } // namespace mojo 94 } // namespace mojo
95 95
96 #endif // SERVICES_MEDIA_COMMON_MEDIA_PIPE_BASE_H_ 96 #endif // SERVICES_MEDIA_COMMON_MEDIA_PIPE_BASE_H_
OLDNEW
« no previous file with comments | « services/media/audio/audio_track_impl.cc ('k') | services/media/common/media_pipe_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698