Home | History | Annotate | Download | only in media
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h"
      5 
      6 #include "content/browser/media/webrtc_internals.h"
      7 #include "content/common/media/peer_connection_tracker_messages.h"
      8 
      9 namespace content {
     10 
     11 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id)
     12     : BrowserMessageFilter(PeerConnectionTrackerMsgStart),
     13       render_process_id_(render_process_id) {}
     14 
     15 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) {
     16   bool handled = true;
     17 
     18   IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message)
     19     IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection,
     20                         OnAddPeerConnection)
     21     IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection,
     22                         OnRemovePeerConnection)
     23     IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_UpdatePeerConnection,
     24                         OnUpdatePeerConnection)
     25     IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddStats, OnAddStats)
     26     IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_GetUserMedia, OnGetUserMedia)
     27     IPC_MESSAGE_UNHANDLED(handled = false)
     28   IPC_END_MESSAGE_MAP()
     29   return handled;
     30 }
     31 
     32 void PeerConnectionTrackerHost::OverrideThreadForMessage(
     33     const IPC::Message& message, BrowserThread::ID* thread) {
     34   if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart)
     35     *thread = BrowserThread::UI;
     36 }
     37 
     38 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() {
     39 }
     40 
     41 void PeerConnectionTrackerHost::OnAddPeerConnection(
     42     const PeerConnectionInfo& info) {
     43   WebRTCInternals::GetInstance()->OnAddPeerConnection(
     44       render_process_id_,
     45       peer_pid(),
     46       info.lid,
     47       info.url,
     48       info.servers,
     49       info.constraints);
     50 }
     51 
     52 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) {
     53   WebRTCInternals::GetInstance()->OnRemovePeerConnection(peer_pid(), lid);
     54 }
     55 
     56 void PeerConnectionTrackerHost::OnUpdatePeerConnection(
     57     int lid, const std::string& type, const std::string& value) {
     58   WebRTCInternals::GetInstance()->OnUpdatePeerConnection(
     59       peer_pid(),
     60       lid,
     61       type,
     62       value);
     63 }
     64 
     65 void PeerConnectionTrackerHost::OnAddStats(int lid,
     66                                            const base::ListValue& value) {
     67   WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value);
     68 }
     69 
     70 void PeerConnectionTrackerHost::OnGetUserMedia(
     71     const std::string& origin,
     72     bool audio,
     73     bool video,
     74     const std::string& audio_constraints,
     75     const std::string& video_constraints) {
     76   WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_,
     77                                                  peer_pid(),
     78                                                  origin,
     79                                                  audio,
     80                                                  video,
     81                                                  audio_constraints,
     82                                                  video_constraints);
     83 }
     84 
     85 }  // namespace content
     86