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.

123 lines
5.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * libjingle
  3. * Copyright 2011, Google Inc.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  19. * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  22. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_
  28. #define TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_
  29. #include <string>
  30. #include "talk/app/webrtc/mediastreaminterface.h"
  31. #include "talk/app/webrtc/peerconnectioninterface.h"
  32. #include "talk/base/scoped_ptr.h"
  33. #include "talk/base/thread.h"
  34. #include "talk/session/media/channelmanager.h"
  35. namespace webrtc {
  36. class PeerConnectionFactory : public PeerConnectionFactoryInterface,
  37. public talk_base::MessageHandler {
  38. public:
  39. virtual talk_base::scoped_refptr<PeerConnectionInterface>
  40. CreatePeerConnection(
  41. const PeerConnectionInterface::IceServers& configuration,
  42. const MediaConstraintsInterface* constraints,
  43. PeerConnectionObserver* observer);
  44. virtual talk_base::scoped_refptr<PeerConnectionInterface>
  45. CreatePeerConnection(
  46. const PeerConnectionInterface::IceServers& configuration,
  47. const MediaConstraintsInterface* constraints,
  48. PortAllocatorFactoryInterface* allocator_factory,
  49. PeerConnectionObserver* observer);
  50. bool Initialize();
  51. virtual talk_base::scoped_refptr<LocalMediaStreamInterface>
  52. CreateLocalMediaStream(const std::string& label);
  53. virtual talk_base::scoped_refptr<AudioSourceInterface> CreateAudioSource(
  54. const MediaConstraintsInterface* constraints);
  55. virtual talk_base::scoped_refptr<VideoSourceInterface> CreateVideoSource(
  56. cricket::VideoCapturer* capturer,
  57. const MediaConstraintsInterface* constraints);
  58. virtual talk_base::scoped_refptr<VideoTrackInterface>
  59. CreateVideoTrack(const std::string& id,
  60. VideoSourceInterface* video_source);
  61. virtual talk_base::scoped_refptr<AudioTrackInterface>
  62. CreateAudioTrack(const std::string& id,
  63. AudioSourceInterface* audio_source);
  64. // Deprecated:
  65. virtual talk_base::scoped_refptr<LocalVideoTrackInterface>
  66. CreateLocalVideoTrack(const std::string& id,
  67. cricket::VideoCapturer* video_device);
  68. // Deprecated:
  69. virtual talk_base::scoped_refptr<LocalAudioTrackInterface>
  70. CreateLocalAudioTrack(const std::string& id,
  71. AudioDeviceModule* audio_device);
  72. virtual cricket::ChannelManager* channel_manager();
  73. virtual talk_base::Thread* signaling_thread();
  74. virtual talk_base::Thread* worker_thread();
  75. protected:
  76. PeerConnectionFactory();
  77. PeerConnectionFactory(
  78. talk_base::Thread* worker_thread,
  79. talk_base::Thread* signaling_thread,
  80. AudioDeviceModule* default_adm);
  81. virtual ~PeerConnectionFactory();
  82. private:
  83. bool Initialize_s();
  84. void Terminate_s();
  85. talk_base::scoped_refptr<AudioSourceInterface> CreateAudioSource_s(
  86. const MediaConstraintsInterface* constraints);
  87. talk_base::scoped_refptr<VideoSourceInterface> CreateVideoSource_s(
  88. cricket::VideoCapturer* capturer,
  89. const MediaConstraintsInterface* constraints);
  90. talk_base::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_s(
  91. const PeerConnectionInterface::IceServers& configuration,
  92. const MediaConstraintsInterface* constraints,
  93. PortAllocatorFactoryInterface* allocator_factory,
  94. PeerConnectionObserver* observer);
  95. // Implements talk_base::MessageHandler.
  96. void OnMessage(talk_base::Message* msg);
  97. bool owns_ptrs_;
  98. talk_base::Thread* signaling_thread_;
  99. talk_base::Thread* worker_thread_;
  100. talk_base::scoped_refptr<PortAllocatorFactoryInterface> allocator_factory_;
  101. // External Audio device used for audio playback.
  102. talk_base::scoped_refptr<AudioDeviceModule> default_adm_;
  103. talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_;
  104. };
  105. } // namespace webrtc
  106. #endif // TALK_APP_WEBRTC_PEERCONNECTIONFACTORY_H_