cast_media_shlib.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2015 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 CHROMECAST_PUBLIC_CAST_MEDIA_SHLIB_H_
  5. #define CHROMECAST_PUBLIC_CAST_MEDIA_SHLIB_H_
  6. #include <stdint.h>
  7. #include <functional>
  8. #include <memory>
  9. #include <string>
  10. #include <utility>
  11. #include <vector>
  12. #include "chromecast_export.h"
  13. #include "volume_control.h"
  14. namespace chromecast {
  15. namespace media {
  16. enum SampleFormat : int;
  17. class MediaPipelineBackend;
  18. struct MediaPipelineDeviceParams;
  19. class VideoPlane;
  20. // Provides access to platform-specific media systems and hardware resources.
  21. // In cast_shell, all usage is from the browser process. An implementation is
  22. // assumed to be in an uninitialized state initially. When uninitialized, no
  23. // API calls will be made except for Initialize, which brings the implementation
  24. // into an initialized state. A call to Finalize returns the implementation to
  25. // its uninitialized state. The implementation must support multiple
  26. // transitions between these states, to support resource grant/revoke events and
  27. // also to allow multiple unit tests to bring up the media systems in isolation
  28. // from other tests.
  29. class CHROMECAST_EXPORT CastMediaShlib {
  30. public:
  31. using ResultCallback =
  32. std::function<void(bool success, const std::string& message)>;
  33. // Initializes platform-specific media systems. Only called when in an
  34. // uninitialized state.
  35. static void Initialize(const std::vector<std::string>& argv);
  36. // Tears down platform-specific media systems and returns to the uninitialized
  37. // state. The implementation must release all media-related hardware
  38. // resources.
  39. static void Finalize();
  40. // Gets the VideoPlane instance for managing the hardware video plane.
  41. // While an implementation is in an initialized state, this function may be
  42. // called at any time. The VideoPlane object must be destroyed in Finalize.
  43. static VideoPlane* GetVideoPlane();
  44. // Creates a media pipeline backend. Called in the browser process for each
  45. // media pipeline and raw audio stream. The caller owns the returned
  46. // MediaPipelineBackend instance.
  47. static MediaPipelineBackend* CreateMediaPipelineBackend(
  48. const MediaPipelineDeviceParams& params);
  49. // Fetches the renderer clock rate (Hz).
  50. static double GetMediaClockRate();
  51. // Fetches the granularity of clock rate adjustments.
  52. static double MediaClockRatePrecision();
  53. // Fetches the possible range of clock rate adjustments.
  54. static void MediaClockRateRange(double* minimum_rate, double* maximum_rate);
  55. // Sets the renderer clock rate (Hz).
  56. static bool SetMediaClockRate(double new_rate);
  57. // Tests if the implementation supports renderer clock rate adjustments.
  58. static bool SupportsMediaClockRateChange();
  59. };
  60. } // namespace media
  61. } // namespace chromecast
  62. #endif // CHROMECAST_PUBLIC_CAST_MEDIA_SHLIB_H_