You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef CALL_CALL_H_
  11. #define CALL_CALL_H_
  12. #include <algorithm>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "api/media_types.h"
  17. #include "call/audio_receive_stream.h"
  18. #include "call/audio_send_stream.h"
  19. #include "call/call_config.h"
  20. #include "call/flexfec_receive_stream.h"
  21. #include "call/packet_receiver.h"
  22. #include "call/rtp_transport_controller_send_interface.h"
  23. #include "call/video_receive_stream.h"
  24. #include "call/video_send_stream.h"
  25. #include "modules/utility/include/process_thread.h"
  26. #include "rtc_base/copy_on_write_buffer.h"
  27. #include "rtc_base/network/sent_packet.h"
  28. #include "rtc_base/network_route.h"
  29. namespace webrtc {
  30. // A Call instance can contain several send and/or receive streams. All streams
  31. // are assumed to have the same remote endpoint and will share bitrate estimates
  32. // etc.
  33. class Call {
  34. public:
  35. using Config = CallConfig;
  36. struct Stats {
  37. std::string ToString(int64_t time_ms) const;
  38. int send_bandwidth_bps = 0; // Estimated available send bandwidth.
  39. int max_padding_bitrate_bps = 0; // Cumulative configured max padding.
  40. int recv_bandwidth_bps = 0; // Estimated available receive bandwidth.
  41. int64_t pacer_delay_ms = 0;
  42. int64_t rtt_ms = -1;
  43. };
  44. static Call* Create(const Call::Config& config);
  45. static Call* Create(const Call::Config& config,
  46. Clock* clock,
  47. std::unique_ptr<ProcessThread> call_thread,
  48. std::unique_ptr<ProcessThread> pacer_thread);
  49. virtual AudioSendStream* CreateAudioSendStream(
  50. const AudioSendStream::Config& config) = 0;
  51. virtual void DestroyAudioSendStream(AudioSendStream* send_stream) = 0;
  52. virtual AudioReceiveStream* CreateAudioReceiveStream(
  53. const AudioReceiveStream::Config& config) = 0;
  54. virtual void DestroyAudioReceiveStream(
  55. AudioReceiveStream* receive_stream) = 0;
  56. virtual VideoSendStream* CreateVideoSendStream(
  57. VideoSendStream::Config config,
  58. VideoEncoderConfig encoder_config) = 0;
  59. virtual VideoSendStream* CreateVideoSendStream(
  60. VideoSendStream::Config config,
  61. VideoEncoderConfig encoder_config,
  62. std::unique_ptr<FecController> fec_controller);
  63. virtual void DestroyVideoSendStream(VideoSendStream* send_stream) = 0;
  64. virtual VideoReceiveStream* CreateVideoReceiveStream(
  65. VideoReceiveStream::Config configuration) = 0;
  66. virtual void DestroyVideoReceiveStream(
  67. VideoReceiveStream* receive_stream) = 0;
  68. // In order for a created VideoReceiveStream to be aware that it is
  69. // protected by a FlexfecReceiveStream, the latter should be created before
  70. // the former.
  71. virtual FlexfecReceiveStream* CreateFlexfecReceiveStream(
  72. const FlexfecReceiveStream::Config& config) = 0;
  73. virtual void DestroyFlexfecReceiveStream(
  74. FlexfecReceiveStream* receive_stream) = 0;
  75. // All received RTP and RTCP packets for the call should be inserted to this
  76. // PacketReceiver. The PacketReceiver pointer is valid as long as the
  77. // Call instance exists.
  78. virtual PacketReceiver* Receiver() = 0;
  79. // This is used to access the transport controller send instance owned by
  80. // Call. The send transport controller is currently owned by Call for legacy
  81. // reasons. (for instance variants of call tests are built on this assumtion)
  82. // TODO(srte): Move ownership of transport controller send out of Call and
  83. // remove this method interface.
  84. virtual RtpTransportControllerSendInterface* GetTransportControllerSend() = 0;
  85. // Returns the call statistics, such as estimated send and receive bandwidth,
  86. // pacing delay, etc.
  87. virtual Stats GetStats() const = 0;
  88. // TODO(skvlad): When the unbundled case with multiple streams for the same
  89. // media type going over different networks is supported, track the state
  90. // for each stream separately. Right now it's global per media type.
  91. virtual void SignalChannelNetworkState(MediaType media,
  92. NetworkState state) = 0;
  93. virtual void OnAudioTransportOverheadChanged(
  94. int transport_overhead_per_packet) = 0;
  95. virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0;
  96. virtual void SetClientBitratePreferences(
  97. const BitrateSettings& preferences) = 0;
  98. virtual ~Call() {}
  99. };
  100. } // namespace webrtc
  101. #endif // CALL_CALL_H_