[M120 Migration][MM] Handle live stream duration and currenttime
[platform/framework/web/chromium-efl.git] / tizen_src / chromium_impl / media / filters / media_player_bridge_capi_tv.h
1 // Copyright 2023 Samsung Electronics Inc. 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
5 #ifndef MEDIA_FILTERS_MEDIA_PLAYER_BRIDGE_CAPI_TV_H_
6 #define MEDIA_FILTERS_MEDIA_PLAYER_BRIDGE_CAPI_TV_H_
7
8 #include <player_product.h>
9
10 #include "media/filters/media_player_bridge_capi.h"
11
12 namespace media {
13
14 enum StreamType {
15   HLS_STREAM = 0,
16   DASH_STREAM,
17   TS_STREAM,
18   OTHER_STREAM,
19 };
20
21 // This class is focus on HBBTV/HLS feature on Tizen TV.
22 class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi {
23  public:
24   MediaPlayerBridgeCapiTV(const GURL& url,
25                           const std::string& user_agent,
26                           double volume);
27   ~MediaPlayerBridgeCapiTV() override;
28   void Initialize(VideoRendererSink* sink) override;
29   bool Play() override;
30   void Prepare() override;
31   void Release() override;
32   void Pause(bool is_media_related_action) override;
33   void SetContentMimeType(const std::string& mime_type) override;
34   void PlaybackCompleteUpdate() override;
35   bool PreloadIfNeeded(int& ret) override;
36   void UpdateMediaType() override;
37   void UpdateDuration() override;
38
39   void AppendUrlHighBitRate(const std::string& url);
40   bool CheckHighBitRate();
41   void HandleDownloadableFontInfo(const std::string& scheme_id_uri,
42                                   const std::string& value,
43                                   const std::string& data,
44                                   int type);
45   void OnPlayerPreloading();
46
47   void OnDrmError(int err_code, char* err_str);
48   void SetParentalRatingResult(bool is_pass) override;
49   void HandleParentalRatingInfo(const std::string& info,
50                                 const std::string& url);
51
52  protected:
53   void PlayerPrepared() override;
54
55  private:
56   void PlayerPreloaded();
57   bool PlayerPrePlay();
58   void SetDisplayAtPausedState();
59   bool CheckLiveStreaming() const;
60   bool HBBTVResourceAcquired();
61   bool SetDrmInfo(std::string& drm_info);
62   bool SetMediaDRMInfo(const std::string&, const std::string&);
63   bool is_preloaded_{false};
64   bool is_player_seek_available_{true};
65   void StartSeekableTimeUpdateTimer();
66   void StopSeekableTimeUpdateTimer();
67   void OnSeekableTimeUpdateTimerFired();
68   void GetAdaptiveStreamingInfo();
69   void UpdateSeekableTime();
70   void ParseDashInfo();
71   bool GetLiveStreamingDuration(int64_t* min, int64_t* max);
72   bool GetDashLiveDuration(int64_t* duration);
73   std::string GetDashInfo();
74
75   StreamType stream_type_{OTHER_STREAM};
76   std::string hbbtv_url_{""};  // url_ + HIGHBITRATE(if mpd)
77   std::string mime_type_ = "";
78   std::string clean_url_{""};  // Original url without suffix t/period
79   std::string mrs_url_{""};
80   std::string content_id_{""};  // clean_url + period,only report to APP
81
82   bool parental_rating_pass_{false};
83
84   base::TimeDelta min_seekable_time_{base::TimeDelta()};
85   base::TimeDelta max_seekable_time_{base::TimeDelta()};
86   base::RepeatingTimer seekable_time_update_timer_;
87   // NOTE: Weak pointers must be invalidated before all other member variables.
88   base::WeakPtrFactory<MediaPlayerBridgeCapiTV> weak_factory_;
89 };
90 }  // namespace media
91
92 #endif  // MEDIA_FILTERS_MEDIA_PLAYER_BRIDGE_CAPI_TV_H_