cast_sender_impl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_CAST_CAST_SENDER_IMPL_H_
  5. #define MEDIA_CAST_CAST_SENDER_IMPL_H_
  6. #include <memory>
  7. #include "base/memory/raw_ptr.h"
  8. #include "base/memory/ref_counted.h"
  9. #include "media/cast/cast_environment.h"
  10. #include "media/cast/cast_sender.h"
  11. #include "media/cast/sender/audio_sender.h"
  12. #include "media/cast/sender/video_sender.h"
  13. namespace media {
  14. namespace cast {
  15. class AudioSender;
  16. class VideoSender;
  17. // This class combines all required sending objects such as the audio and video
  18. // senders, pacer, packet receiver and frame input.
  19. class CastSenderImpl final : public CastSender {
  20. public:
  21. CastSenderImpl(scoped_refptr<CastEnvironment> cast_environment,
  22. CastTransport* const transport_sender);
  23. void InitializeAudio(const FrameSenderConfig& audio_config,
  24. StatusChangeOnceCallback status_change_cb) final;
  25. void InitializeVideo(
  26. const FrameSenderConfig& video_config,
  27. const StatusChangeCallback& status_change_cb,
  28. const CreateVideoEncodeAcceleratorCallback& create_vea_cb) final;
  29. void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay) final;
  30. CastSenderImpl(const CastSenderImpl&) = delete;
  31. CastSenderImpl& operator=(const CastSenderImpl&) = delete;
  32. ~CastSenderImpl() final;
  33. scoped_refptr<AudioFrameInput> audio_frame_input() final;
  34. scoped_refptr<VideoFrameInput> video_frame_input() final;
  35. private:
  36. void ReceivedPacket(std::unique_ptr<Packet> packet);
  37. void OnAudioStatusChange(StatusChangeOnceCallback status_change_cb,
  38. OperationalStatus status);
  39. void OnVideoStatusChange(const StatusChangeCallback& status_change_cb,
  40. OperationalStatus status);
  41. std::unique_ptr<AudioSender> audio_sender_;
  42. std::unique_ptr<VideoSender> video_sender_;
  43. scoped_refptr<AudioFrameInput> audio_frame_input_;
  44. scoped_refptr<VideoFrameInput> video_frame_input_;
  45. scoped_refptr<CastEnvironment> cast_environment_;
  46. // The transport sender is owned by the owner of the CastSender, and should be
  47. // valid throughout the lifetime of the CastSender.
  48. const raw_ptr<CastTransport> transport_sender_;
  49. // NOTE: Weak pointers must be invalidated before all other member variables.
  50. base::WeakPtrFactory<CastSenderImpl> weak_factory_{this};
  51. };
  52. } // namespace cast
  53. } // namespace media
  54. #endif // MEDIA_CAST_CAST_SENDER_IMPL_H_