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

Unified Diff: chromecast/renderer/media/cma_message_filter_proxy.h

Issue 814403002: [Chromecast] Add CmaMediaRendererFactory and IPC proxy components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
Index: chromecast/renderer/media/cma_message_filter_proxy.h
diff --git a/chromecast/renderer/media/cma_message_filter_proxy.h b/chromecast/renderer/media/cma_message_filter_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..0930f19938e62768fc71dcbb948d6f50d51bdfed
--- /dev/null
+++ b/chromecast/renderer/media/cma_message_filter_proxy.h
@@ -0,0 +1,135 @@
+// Copyright 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 CHROMECAST_RENDERER_MEDIA_CMA_MESSAGE_FILTER_PROXY_H_
+#define CHROMECAST_RENDERER_MEDIA_CMA_MESSAGE_FILTER_PROXY_H_
+
+#include "base/id_map.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/shared_memory.h"
+#include "base/sync_socket.h"
+#include "chromecast/common/media/cma_ipc_common.h"
+#include "chromecast/media/cma/pipeline/av_pipeline_client.h"
+#include "chromecast/media/cma/pipeline/media_pipeline_client.h"
+#include "chromecast/media/cma/pipeline/video_pipeline_client.h"
+#include "ipc/message_filter.h"
+#include "media/base/buffering_state.h"
+#include "media/base/pipeline_status.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace chromecast {
+namespace media {
+
+typedef base::Callback<void(
+ bool, base::SharedMemoryHandle, base::FileDescriptor)> AvPipeCB;
+
+class CmaMessageFilterProxy : public IPC::MessageFilter {
+ public:
+ struct MediaDelegate {
+ MediaDelegate();
+ ~MediaDelegate();
+
+ ::media::PipelineStatusCB state_changed_cb;
+ MediaPipelineClient client;
+ };
+
+ struct AudioDelegate {
+ AudioDelegate();
+ ~AudioDelegate();
+
+ AvPipeCB av_pipe_cb;
+ base::Closure pipe_read_cb;
+ ::media::PipelineStatusCB state_changed_cb;
+ AvPipelineClient client;
+ };
+
+ struct VideoDelegate {
+ VideoDelegate();
+ ~VideoDelegate();
+
+ AvPipeCB av_pipe_cb;
+ base::Closure pipe_read_cb;
+ ::media::PipelineStatusCB state_changed_cb;
+ VideoPipelineClient client;
+ };
+
+ explicit CmaMessageFilterProxy(
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
+
+ // Getter for the one CmaMessageFilterHost object.
+ static CmaMessageFilterProxy* Get();
+
+ int CreateChannel();
+ void DestroyChannel(int id);
+
+ // For adding/removing delegates.
+ bool SetMediaDelegate(int id, const MediaDelegate& media_delegate);
+ bool SetAudioDelegate(int id, const AudioDelegate& audio_delegate);
+ bool SetVideoDelegate(int id, const VideoDelegate& video_delegate);
+
+ // Sends an IPC message using |channel_|.
+ bool Send(scoped_ptr<IPC::Message> message);
+
+ // IPC::ChannelProxy::MessageFilter implementation. Called on IO thread.
+ bool OnMessageReceived(const IPC::Message& message) override;
+ void OnFilterAdded(IPC::Sender* sender) override;
+ void OnFilterRemoved() override;
+ void OnChannelClosing() override;
+
+ protected:
+ ~CmaMessageFilterProxy() override;
+
+ private:
+ struct DelegateEntry {
+ DelegateEntry();
+ ~DelegateEntry();
+
+ MediaDelegate media_delegate;
+ AudioDelegate audio_delegate;
+ VideoDelegate video_delegate;
+ };
+
+ void OnAvPipeCreated(int id,
+ TrackId track_id,
+ bool status,
+ base::SharedMemoryHandle shared_memory_handle,
+ base::FileDescriptor socket_handle);
+ void OnPipeRead(int id, TrackId track_id);
+ void OnMediaStateChanged(int id, ::media::PipelineStatus status);
+ void OnTrackStateChanged(int id, TrackId track_id,
+ ::media::PipelineStatus status);
+ void OnEos(int id, TrackId track_id);
+ void OnTimeUpdate(int id,
+ base::TimeDelta time,
+ base::TimeDelta max_time,
+ base::TimeTicks stc);
+ void OnBufferingNotification(int id, ::media::BufferingState state);
+ void OnPlaybackError(int id, TrackId track_id,
+ ::media::PipelineStatus status);
+ void OnStatisticsUpdated(int id, TrackId track_id,
+ const ::media::PipelineStatistics& stats);
+ void OnNaturalSizeChanged(int id, TrackId track_id,
+ const gfx::Size& natural_size);
+
+ // The singleton instance for this filter.
+ static CmaMessageFilterProxy* filter_;
+
+ // A map of media ids to delegates.
+ IDMap<DelegateEntry> delegates_;
+
+ IPC::Sender* sender_;
+
+ scoped_refptr<base::MessageLoopProxy> const io_message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(CmaMessageFilterProxy);
+};
+
+} // namespace media
+} // namespace chromecast
+
+#endif // CHROMECAST_RENDERER_MEDIA_CMA_MESSAGE_FILTER_PROXY_H_
« no previous file with comments | « chromecast/renderer/media/cma_media_renderer_factory.cc ('k') | chromecast/renderer/media/cma_message_filter_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698