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

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp

Issue 2972003002: RTCPeerConnection.ontrack event added. (Closed)
Patch Set: Le merge Created 3 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "modules/peerconnection/RTCRtpReceiver.h" 68 #include "modules/peerconnection/RTCRtpReceiver.h"
69 #include "modules/peerconnection/RTCRtpSender.h" 69 #include "modules/peerconnection/RTCRtpSender.h"
70 #include "modules/peerconnection/RTCSessionDescription.h" 70 #include "modules/peerconnection/RTCSessionDescription.h"
71 #include "modules/peerconnection/RTCSessionDescriptionCallback.h" 71 #include "modules/peerconnection/RTCSessionDescriptionCallback.h"
72 #include "modules/peerconnection/RTCSessionDescriptionInit.h" 72 #include "modules/peerconnection/RTCSessionDescriptionInit.h"
73 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h" 73 #include "modules/peerconnection/RTCSessionDescriptionRequestImpl.h"
74 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h" 74 #include "modules/peerconnection/RTCSessionDescriptionRequestPromiseImpl.h"
75 #include "modules/peerconnection/RTCStatsCallback.h" 75 #include "modules/peerconnection/RTCStatsCallback.h"
76 #include "modules/peerconnection/RTCStatsReport.h" 76 #include "modules/peerconnection/RTCStatsReport.h"
77 #include "modules/peerconnection/RTCStatsRequestImpl.h" 77 #include "modules/peerconnection/RTCStatsRequestImpl.h"
78 #include "modules/peerconnection/RTCTrackEvent.h"
78 #include "modules/peerconnection/RTCVoidRequestImpl.h" 79 #include "modules/peerconnection/RTCVoidRequestImpl.h"
79 #include "modules/peerconnection/RTCVoidRequestPromiseImpl.h" 80 #include "modules/peerconnection/RTCVoidRequestPromiseImpl.h"
80 #include "platform/RuntimeEnabledFeatures.h" 81 #include "platform/RuntimeEnabledFeatures.h"
81 #include "platform/bindings/Microtask.h" 82 #include "platform/bindings/Microtask.h"
82 #include "platform/bindings/ScriptState.h" 83 #include "platform/bindings/ScriptState.h"
83 #include "platform/bindings/V8ThrowException.h" 84 #include "platform/bindings/V8ThrowException.h"
84 #include "platform/peerconnection/RTCAnswerOptionsPlatform.h" 85 #include "platform/peerconnection/RTCAnswerOptionsPlatform.h"
85 #include "platform/peerconnection/RTCOfferOptionsPlatform.h" 86 #include "platform/peerconnection/RTCOfferOptionsPlatform.h"
86 #include "platform/wtf/CurrentTime.h" 87 #include "platform/wtf/CurrentTime.h"
87 #include "platform/wtf/PtrUtil.h" 88 #include "platform/wtf/PtrUtil.h"
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 } 1437 }
1437 1438
1438 void RTCPeerConnection::DidChangeICEConnectionState( 1439 void RTCPeerConnection::DidChangeICEConnectionState(
1439 ICEConnectionState new_state) { 1440 ICEConnectionState new_state) {
1440 DCHECK(!closed_); 1441 DCHECK(!closed_);
1441 DCHECK(GetExecutionContext()->IsContextThread()); 1442 DCHECK(GetExecutionContext()->IsContextThread());
1442 ChangeIceConnectionState(new_state); 1443 ChangeIceConnectionState(new_state);
1443 } 1444 }
1444 1445
1445 void RTCPeerConnection::DidAddRemoteStream( 1446 void RTCPeerConnection::DidAddRemoteStream(
1446 const WebMediaStream& remote_stream) { 1447 const WebMediaStream& remote_stream,
1448 WebVector<std::unique_ptr<WebRTCRtpReceiver>>* stream_web_rtp_receivers) {
1447 DCHECK(!closed_); 1449 DCHECK(!closed_);
1448 DCHECK(GetExecutionContext()->IsContextThread()); 1450 DCHECK(GetExecutionContext()->IsContextThread());
1449 1451
1450 if (signaling_state_ == kSignalingStateClosed) 1452 if (signaling_state_ == kSignalingStateClosed)
1451 return; 1453 return;
1452 1454
1453 MediaStream* stream = 1455 MediaStream* stream =
1454 MediaStream::Create(GetExecutionContext(), remote_stream); 1456 MediaStream::Create(GetExecutionContext(), remote_stream);
1455 remote_streams_.push_back(stream); 1457 remote_streams_.push_back(stream);
1456 stream->RegisterObserver(this); 1458 stream->RegisterObserver(this);
1457 for (auto& track : stream->getTracks()) { 1459 for (auto& track : stream->getTracks()) {
1458 DCHECK(track->Component()); 1460 DCHECK(track->Component());
1459 tracks_.insert(track->Component(), track); 1461 tracks_.insert(track->Component(), track);
1460 } 1462 }
1461 1463
1462 ScheduleDispatchEvent( 1464 ScheduleDispatchEvent(
1463 MediaStreamEvent::Create(EventTypeNames::addstream, stream)); 1465 MediaStreamEvent::Create(EventTypeNames::addstream, stream));
1466
1467 // TODO(hbos): ...
1468 HeapVector<Member<MediaStream>> streams(1, stream);
1469 for (auto& track : stream->getTracks()) {
1470 std::unique_ptr<WebRTCRtpReceiver> track_web_rtp_receiver;
1471 for (auto& web_rtp_receiver : *stream_web_rtp_receivers) {
1472 if (static_cast<String>(web_rtp_receiver->Track().Id()) == track->id()) {
1473 track_web_rtp_receiver.reset(web_rtp_receiver.release());
1474 break;
1475 }
1476 }
1477 DCHECK(track_web_rtp_receiver);
1478 uintptr_t id = track_web_rtp_receiver->Id();
1479 RTCRtpReceiver* track_rtp_receiver = nullptr;
1480 const auto it = rtp_receivers_.find(id);
1481 if (it != rtp_receivers_.end()) {
1482 track_rtp_receiver = it->value;
1483 } else {
1484 // There does not exist a |RTCRtpReceiver| for this |WebRTCRtpReceiver|
1485 // yet, create it.
1486 MediaStreamTrack* track = GetTrack(track_web_rtp_receiver->Track());
1487 DCHECK(track);
1488 track_rtp_receiver =
1489 new RTCRtpReceiver(std::move(track_web_rtp_receiver), track);
1490 rtp_receivers_.insert(id, track_rtp_receiver);
1491 }
1492 ScheduleDispatchEvent(
1493 new RTCTrackEvent(track_rtp_receiver, track, streams));
1494 }
1464 } 1495 }
1465 1496
1466 void RTCPeerConnection::DidRemoveRemoteStream( 1497 void RTCPeerConnection::DidRemoveRemoteStream(
1467 const WebMediaStream& remote_stream) { 1498 const WebMediaStream& remote_stream) {
1468 DCHECK(!closed_); 1499 DCHECK(!closed_);
1469 DCHECK(GetExecutionContext()->IsContextThread()); 1500 DCHECK(GetExecutionContext()->IsContextThread());
1470 1501
1471 MediaStreamDescriptor* stream_descriptor = remote_stream; 1502 MediaStreamDescriptor* stream_descriptor = remote_stream;
1472 DCHECK(stream_descriptor->Client()); 1503 DCHECK(stream_descriptor->Client());
1473 1504
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 visitor->Trace(rtp_senders_); 1686 visitor->Trace(rtp_senders_);
1656 visitor->Trace(rtp_receivers_); 1687 visitor->Trace(rtp_receivers_);
1657 visitor->Trace(dispatch_scheduled_event_runner_); 1688 visitor->Trace(dispatch_scheduled_event_runner_);
1658 visitor->Trace(scheduled_events_); 1689 visitor->Trace(scheduled_events_);
1659 EventTargetWithInlineData::Trace(visitor); 1690 EventTargetWithInlineData::Trace(visitor);
1660 SuspendableObject::Trace(visitor); 1691 SuspendableObject::Trace(visitor);
1661 MediaStreamObserver::Trace(visitor); 1692 MediaStreamObserver::Trace(visitor);
1662 } 1693 }
1663 1694
1664 } // namespace blink 1695 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698