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

Side by Side Diff: talk/media/base/mediachannel.h

Issue 1363573002: Wire up transport sequence number / send time callbacks to webrtc via libjingle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cleanups. Created 5 years, 2 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 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 enum DtmfFlags { 516 enum DtmfFlags {
517 DF_PLAY = 0x01, 517 DF_PLAY = 0x01,
518 DF_SEND = 0x02, 518 DF_SEND = 0x02,
519 }; 519 };
520 520
521 class MediaChannel : public sigslot::has_slots<> { 521 class MediaChannel : public sigslot::has_slots<> {
522 public: 522 public:
523 class NetworkInterface { 523 class NetworkInterface {
524 public: 524 public:
525 enum SocketType { ST_RTP, ST_RTCP }; 525 enum SocketType { ST_RTP, ST_RTCP };
526 virtual bool SendPacket( 526 virtual bool SendPacket(rtc::Buffer* packet,
527 rtc::Buffer* packet, 527 const rtc::PacketOptions& options) = 0;
528 rtc::DiffServCodePoint dscp = rtc::DSCP_NO_CHANGE) = 0; 528 virtual bool SendRtcp(rtc::Buffer* packet,
529 virtual bool SendRtcp( 529 const rtc::PacketOptions& options) = 0;
530 rtc::Buffer* packet,
531 rtc::DiffServCodePoint dscp = rtc::DSCP_NO_CHANGE) = 0;
532 virtual int SetOption(SocketType type, rtc::Socket::Option opt, 530 virtual int SetOption(SocketType type, rtc::Socket::Option opt,
533 int option) = 0; 531 int option) = 0;
534 virtual ~NetworkInterface() {} 532 virtual ~NetworkInterface() {}
535 }; 533 };
536 534
537 MediaChannel() : network_interface_(NULL) {} 535 MediaChannel() : network_interface_(NULL) {}
538 virtual ~MediaChannel() {} 536 virtual ~MediaChannel() {}
539 537
540 // Sets the abstract interface class for sending RTP/RTCP data. 538 // Sets the abstract interface class for sending RTP/RTCP data.
541 virtual void SetInterface(NetworkInterface *iface) { 539 virtual void SetInterface(NetworkInterface *iface) {
542 rtc::CritScope cs(&network_interface_crit_); 540 rtc::CritScope cs(&network_interface_crit_);
543 network_interface_ = iface; 541 network_interface_ = iface;
544 } 542 }
545 543
546 // Called when a RTP packet is received. 544 // Called when a RTP packet is received.
547 virtual void OnPacketReceived(rtc::Buffer* packet, 545 virtual void OnPacketReceived(rtc::Buffer* packet,
548 const rtc::PacketTime& packet_time) = 0; 546 const rtc::PacketTime& packet_time) = 0;
549 // Called when a RTCP packet is received. 547 // Called when a RTCP packet is received.
550 virtual void OnRtcpReceived(rtc::Buffer* packet, 548 virtual void OnRtcpReceived(rtc::Buffer* packet,
551 const rtc::PacketTime& packet_time) = 0; 549 const rtc::PacketTime& packet_time) = 0;
550 virtual void OnSentPacket(const rtc::SentPacket& sent_packet) {}
552 // Called when the socket's ability to send has changed. 551 // Called when the socket's ability to send has changed.
553 virtual void OnReadyToSend(bool ready) = 0; 552 virtual void OnReadyToSend(bool ready) = 0;
554 // Creates a new outgoing media stream with SSRCs and CNAME as described 553 // Creates a new outgoing media stream with SSRCs and CNAME as described
555 // by sp. 554 // by sp.
556 virtual bool AddSendStream(const StreamParams& sp) = 0; 555 virtual bool AddSendStream(const StreamParams& sp) = 0;
557 // Removes an outgoing media stream. 556 // Removes an outgoing media stream.
558 // ssrc must be the first SSRC of the media stream if the stream uses 557 // ssrc must be the first SSRC of the media stream if the stream uses
559 // multiple SSRCs. 558 // multiple SSRCs.
560 virtual bool RemoveSendStream(uint32 ssrc) = 0; 559 virtual bool RemoveSendStream(uint32 ssrc) = 0;
561 // Creates a new incoming media stream with SSRCs and CNAME as described 560 // Creates a new incoming media stream with SSRCs and CNAME as described
562 // by sp. 561 // by sp.
563 virtual bool AddRecvStream(const StreamParams& sp) = 0; 562 virtual bool AddRecvStream(const StreamParams& sp) = 0;
564 // Removes an incoming media stream. 563 // Removes an incoming media stream.
565 // ssrc must be the first SSRC of the media stream if the stream uses 564 // ssrc must be the first SSRC of the media stream if the stream uses
566 // multiple SSRCs. 565 // multiple SSRCs.
567 virtual bool RemoveRecvStream(uint32 ssrc) = 0; 566 virtual bool RemoveRecvStream(uint32 ssrc) = 0;
568 567
569 // Returns the absoulte sendtime extension id value from media channel. 568 // Returns the absoulte sendtime extension id value from media channel.
570 virtual int GetRtpSendTimeExtnId() const { 569 virtual int GetRtpSendTimeExtnId() const {
571 return -1; 570 return -1;
572 } 571 }
573 572
574 // Base method to send packet using NetworkInterface. 573 // Base method to send packet using NetworkInterface.
575 bool SendPacket(rtc::Buffer* packet) { 574 bool SendPacket(rtc::Buffer* packet, const rtc::PacketOptions& options) {
576 return DoSendPacket(packet, false); 575 return DoSendPacket(packet, false, options);
577 } 576 }
578 577
579 bool SendRtcp(rtc::Buffer* packet) { 578 bool SendRtcp(rtc::Buffer* packet, const rtc::PacketOptions& options) {
580 return DoSendPacket(packet, true); 579 return DoSendPacket(packet, true, options);
581 } 580 }
582 581
583 int SetOption(NetworkInterface::SocketType type, 582 int SetOption(NetworkInterface::SocketType type,
584 rtc::Socket::Option opt, 583 rtc::Socket::Option opt,
585 int option) { 584 int option) {
586 rtc::CritScope cs(&network_interface_crit_); 585 rtc::CritScope cs(&network_interface_crit_);
587 if (!network_interface_) 586 if (!network_interface_)
588 return -1; 587 return -1;
589 588
590 return network_interface_->SetOption(type, opt, option); 589 return network_interface_->SetOption(type, opt, option);
591 } 590 }
592 591
593 protected: 592 protected:
594 // This method sets DSCP |value| on both RTP and RTCP channels. 593 // This method sets DSCP |value| on both RTP and RTCP channels.
595 int SetDscp(rtc::DiffServCodePoint value) { 594 int SetDscp(rtc::DiffServCodePoint value) {
596 int ret; 595 int ret;
597 ret = SetOption(NetworkInterface::ST_RTP, 596 ret = SetOption(NetworkInterface::ST_RTP,
598 rtc::Socket::OPT_DSCP, 597 rtc::Socket::OPT_DSCP,
599 value); 598 value);
600 if (ret == 0) { 599 if (ret == 0) {
601 ret = SetOption(NetworkInterface::ST_RTCP, 600 ret = SetOption(NetworkInterface::ST_RTCP,
602 rtc::Socket::OPT_DSCP, 601 rtc::Socket::OPT_DSCP,
603 value); 602 value);
604 } 603 }
605 return ret; 604 return ret;
606 } 605 }
607 606
608 private: 607 private:
609 bool DoSendPacket(rtc::Buffer* packet, bool rtcp) { 608 bool DoSendPacket(rtc::Buffer* packet,
609 bool rtcp,
610 const rtc::PacketOptions& options) {
610 rtc::CritScope cs(&network_interface_crit_); 611 rtc::CritScope cs(&network_interface_crit_);
611 if (!network_interface_) 612 if (!network_interface_)
612 return false; 613 return false;
613 614
614 return (!rtcp) ? network_interface_->SendPacket(packet) : 615 return (!rtcp) ? network_interface_->SendPacket(packet, options)
615 network_interface_->SendRtcp(packet); 616 : network_interface_->SendRtcp(packet, options);
616 } 617 }
617 618
618 // |network_interface_| can be accessed from the worker_thread and 619 // |network_interface_| can be accessed from the worker_thread and
619 // from any MediaEngine threads. This critical section is to protect accessing 620 // from any MediaEngine threads. This critical section is to protect accessing
620 // of network_interface_ object. 621 // of network_interface_ object.
621 rtc::CriticalSection network_interface_crit_; 622 rtc::CriticalSection network_interface_crit_;
622 NetworkInterface* network_interface_; 623 NetworkInterface* network_interface_;
623 }; 624 };
624 625
625 enum SendFlags { 626 enum SendFlags {
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 // Signal when the media channel is ready to send the stream. Arguments are: 1276 // Signal when the media channel is ready to send the stream. Arguments are:
1276 // writable(bool) 1277 // writable(bool)
1277 sigslot::signal1<bool> SignalReadyToSend; 1278 sigslot::signal1<bool> SignalReadyToSend;
1278 // Signal for notifying that the remote side has closed the DataChannel. 1279 // Signal for notifying that the remote side has closed the DataChannel.
1279 sigslot::signal1<uint32> SignalStreamClosedRemotely; 1280 sigslot::signal1<uint32> SignalStreamClosedRemotely;
1280 }; 1281 };
1281 1282
1282 } // namespace cricket 1283 } // namespace cricket
1283 1284
1284 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_ 1285 #endif // TALK_MEDIA_BASE_MEDIACHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698