peer_connection.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "api.h"
  3. #include <stdint.h>
  4. #include "../common/comm.h"
  5. #include "../common/iobuffer.h"
  6. class IOverlayVideo;
  7. class SocketRemote;
  8. class CPeerConnection
  9. {
  10. public:
  11. CPeerConnection(SocketRemote * c);
  12. virtual ~CPeerConnection();
  13. void Initialize(int32_t peer, int32_t index);
  14. //static void ConnectionCallBack(void* UserData);
  15. static void LocalSdpReadytoSendCallback(void* user_data, int32_t peer, int32_t view, const char* type, const char* sdp_data);
  16. static void IceCandidateReadytoSendCallback(void* user_data, int32_t peer, int32_t view, const char* sdp, int32_t sdp_mline_index, const char* sdp_mid);
  17. void AddLocalVideoFrameReady(PeerConnectionVideoFrameCallback fn, void* user_data);
  18. void AddLocalAudioTrack();
  19. void RemoveLocalAudioTrack();
  20. void AddRemoteVideoFrameReady(PeerConnectionVideoFrameCallback fn, void* user_data);
  21. void AddDataChannel(bool ordered, bool reliable);
  22. void RemoveDataChannel();
  23. void SetRemoteDescription(const char* type, std::string sdp);
  24. bool CreateAnswer();
  25. bool CreateOffer();
  26. void AddIceCandidate(const char* sdp, int32_t sdp_mline_index, const char* sdp_mid);
  27. void Close();
  28. IOverlayVideo* CreateOverlayVideo();
  29. void AddLocalVideoTrack(IOverlayVideo* render);
  30. // void AddLocalVideoTrack(int32_t index,const std::string& label,const std::string &videourl,int32_t width,int32_t height);
  31. private:
  32. //void OnConnect();
  33. void OnLocalSdpReadytoSend(int32_t peer, int32_t view, const char* type, const char* sdp);
  34. void OnIceCandidateReadytoSend(int32_t peer, int32_t view, const char* sdp, int32_t sdp_mline_index, const char* sdp_mid);
  35. private:
  36. PeerConnectionHandle _nativeHandle;
  37. ChannelType _type;
  38. SocketRemote* _client;
  39. };