[M120 Migration][hbbtv] Audio tracks count notification 50/308750/5
authorzhishun.zhou <zhishun.zhou@samsung.com>
Fri, 29 Mar 2024 12:43:42 +0000 (20:43 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 11 Apr 2024 17:19:14 +0000 (17:19 +0000)
Support EWK callback: "notify,audio,tracks,count".
For mse, get audio track from chunkDemuxer.
For url, get audio track from mm api.

Patch from:
https://review.tizen.org/gerrit/#/c/292739/

Change-Id: Ibec7528293a8136fde387662bd213c02e2768806
Signed-off-by: wuxiaoliang <xliang.wu@samsung.com>
Signed-off-by: zhishun.zhou <zhishun.zhou@samsung.com>
32 files changed:
content/public/browser/web_contents_delegate.h
media/base/demuxer.h
media/base/pipeline.h
media/base/pipeline_impl.cc
media/base/pipeline_impl.h
media/base/renderer.h
media/filters/chunk_demuxer.cc
media/filters/chunk_demuxer.h
media/filters/demuxer_manager.cc
media/filters/demuxer_manager.h
media/filters/pipeline_controller.cc
media/filters/pipeline_controller.h
media/mojo/clients/mojo_renderer.cc
media/mojo/clients/mojo_renderer.h
media/mojo/clients/mojo_renderer_wrapper.cc
media/mojo/clients/mojo_renderer_wrapper.h
media/mojo/mojom/renderer.mojom
media/mojo/services/mojo_renderer_service.cc
media/mojo/services/mojo_renderer_service.h
third_party/blink/renderer/platform/media/web_media_player_impl.cc
third_party/blink/renderer/platform/media/web_media_player_impl.h
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.cc
tizen_src/chromium_impl/content/browser/media/tizen_renderer_impl.h
tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.cc
tizen_src/chromium_impl/media/filters/media_player_bridge_capi_tv.h
tizen_src/chromium_impl/media/filters/media_player_tizen_client.h
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/eweb_view_callbacks.h
tizen_src/ewk/efl_integration/public/ewk_media_playback_info.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h

index de949f9..ec8def3 100644 (file)
@@ -757,6 +757,7 @@ class CONTENT_EXPORT WebContentsDelegate {
                                           const std::string& value,
                                           const std::string& data,
                                           int type) {}
+  virtual void NotifyAudioTracksCount(int player_id, unsigned count) {}
   virtual void NotifySubtitleState(int state, double time_stamp = 0.0) {}
   virtual void NotifySubtitlePlay(int active_track_id,
                                   const std::string& url,
index 50acd92..980e0d6 100644 (file)
@@ -88,6 +88,7 @@ class MEDIA_EXPORT Demuxer : public MediaResource {
     kMediaUrlDemuxer,
   };
 
+  using AudioTracksCountChangedCB = base::RepeatingCallback<void(unsigned)>;
   Demuxer();
 
   Demuxer(const Demuxer&) = delete;
index 233360b..359e52e 100644 (file)
@@ -315,6 +315,7 @@ class MEDIA_EXPORT Pipeline {
 #endif
 #if BUILDFLAG(IS_TIZEN_TV)
   virtual void SetContentMimeType(const std::string& mime_type) = 0;
+  virtual void AudioTracksCountChanged(unsigned count) = 0;
   virtual void SetParentalRatingResult(bool is_pass) = 0;
   virtual void SetActiveTextTrack(int id, bool is_in_band) = 0;
   virtual void SetActiveAudioTrack(int index) = 0;
index a026dd0..bfb8af8 100644 (file)
@@ -117,6 +117,7 @@ class PipelineImpl::RendererWrapper final : public DemuxerHost,
 #endif
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type);
+  void AudioTracksCountChanged(unsigned count);
   void WaitSignal();
   void SetParentalRatingResult(bool is_pass);
   void SetActiveTextTrack(int id, bool is_in_band);
@@ -739,6 +740,16 @@ void PipelineImpl::RendererWrapper::SetParentalRatingResult(bool is_pass) {
     LOG(ERROR) << "renderer is null";
 }
 
+void PipelineImpl::RendererWrapper::AudioTracksCountChanged(unsigned count) {
+  DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
+  if (!shared_state_.renderer) {
+    LOG(ERROR) << "renderer is null";
+    return;
+  }
+
+  shared_state_.renderer->AudioTracksCountChanged(count);
+}
+
 void PipelineImpl::RendererWrapper::SetActiveTextTrack(int id,
                                                        bool is_in_band) {
   DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
@@ -2095,6 +2106,15 @@ void PipelineImpl::SetParentalRatingResult(bool is_pass) {
   renderer_wrapper_->SetParentalRatingResult(is_pass);
 }
 
+void PipelineImpl::AudioTracksCountChanged(unsigned count) {
+  DVLOG(2) << __func__;
+  DCHECK(thread_checker_.CalledOnValidThread());
+  media_task_runner_->PostTask(
+      FROM_HERE,
+      base::BindOnce(&RendererWrapper::AudioTracksCountChanged,
+                     base::Unretained(renderer_wrapper_.get()), count));
+}
+
 void PipelineImpl::SetActiveTextTrack(int id, bool is_in_band) {
   DVLOG(2) << __func__;
   DCHECK(thread_checker_.CalledOnValidThread());
index e6de104..e5c4fca 100644 (file)
@@ -176,6 +176,7 @@ class MEDIA_EXPORT PipelineImpl : public Pipeline {
   void OnMetadata(const PipelineMetadata& metadata);
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type) override;
+  void AudioTracksCountChanged(unsigned count) override;
   void NotifyTrackInfoToBrowser(int active_track_id);
   void SetParentalRatingResult(bool is_pass) override;
   void AddTrackInfo(media::MediaTrackInfo trackinfo);
index e32caab..ca8d483 100644 (file)
@@ -126,6 +126,7 @@ class MEDIA_EXPORT Renderer {
   using GetVideoIdCB = base::OnceCallback<void(int32_t)>;
   virtual void GetVideoId(GetVideoIdCB cb) {}
   virtual void SetContentMimeType(const std::string& mime_type) {}
+  virtual void AudioTracksCountChanged(unsigned count) {}
   virtual void SetParentalRatingResult(bool is_pass) {}
   virtual void SetActiveTextTrack(int id, bool is_in_band) {}
   virtual void SetActiveAudioTrack(int index) {}
index 8daa31a..a48917d 100644 (file)
@@ -477,10 +477,12 @@ ChunkDemuxer::ChunkDemuxer(
     base::OnceClosure open_cb,
     base::RepeatingClosure progress_cb,
     EncryptedMediaInitDataCB encrypted_media_init_data_cb,
+    AudioTracksCountChangedCB audio_tracks_count_changed_cb,
     MediaLog* media_log)
     : open_cb_(std::move(open_cb)),
       progress_cb_(std::move(progress_cb)),
       encrypted_media_init_data_cb_(std::move(encrypted_media_init_data_cb)),
+      audio_tracks_count_changed_cb_(std::move(audio_tracks_count_changed_cb)),
       media_log_(media_log) {
   DCHECK(open_cb_);
   DCHECK(encrypted_media_init_data_cb_);
@@ -819,7 +821,24 @@ void ChunkDemuxer::SetTracksWatcher(const std::string& id,
                                     MediaTracksUpdatedCB tracks_updated_cb) {
   base::AutoLock auto_lock(lock_);
   CHECK(IsValidId_Locked(id));
-  source_state_map_[id]->SetTracksWatcher(std::move(tracks_updated_cb));
+  media_tracks_updated_cb_[id] = tracks_updated_cb;
+  source_state_map_[id]->SetTracksWatcher(base::BindRepeating(
+      &ChunkDemuxer::InitSegmentReceived, base::Unretained(this), id));
+}
+
+void ChunkDemuxer::InitSegmentReceived(const std::string& id,
+                                       std::unique_ptr<MediaTracks> tracks) {
+  bool audio_track_detected = false;
+  for (const auto& track : tracks->tracks()) {
+    if (track->type() == MediaTrack::Type::kAudio) {
+      audio_tracks_count_[id]++;
+      audio_tracks_count_total_++;
+      audio_track_detected = true;
+    }
+  }
+  if (audio_track_detected)
+    audio_tracks_count_changed_cb_.Run(audio_tracks_count_total_);
+  media_tracks_updated_cb_[id].Run(std::move(tracks));
 }
 
 void ChunkDemuxer::SetParseWarningCallback(
@@ -861,6 +880,11 @@ void ChunkDemuxer::RemoveId(const std::string& id) {
     CHECK(stream_found);
   }
   id_to_streams_map_.erase(id);
+
+  audio_tracks_count_total_ -= audio_tracks_count_[id];
+  audio_tracks_count_.erase(id);
+  audio_tracks_count_changed_cb_.Run(audio_tracks_count_total_);
+  media_tracks_updated_cb_.erase(id);
 }
 
 Ranges<base::TimeDelta> ChunkDemuxer::GetBufferedRanges(
index b38efa0..2a2d52b 100644 (file)
@@ -223,6 +223,7 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
   ChunkDemuxer(base::OnceClosure open_cb,
                base::RepeatingClosure progress_cb,
                EncryptedMediaInitDataCB encrypted_media_init_data_cb,
+               AudioTracksCountChangedCB audio_tracks_count_changed_cb,
                MediaLog* media_log);
 
   ChunkDemuxer(const ChunkDemuxer&) = delete;
@@ -501,6 +502,9 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
   void OnFramerateSet(const StreamFramerate::Framerate& framerate);
 #endif
 
+  void InitSegmentReceived(const std::string& id,
+                           std::unique_ptr<MediaTracks> tracks);
+
   // Creates a DemuxerStream of the specified |type| for the SourceBufferState
   // with the given |source_id|.
   // Returns a pointer to a new ChunkDemuxerStream instance, which is owned by
@@ -561,6 +565,9 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
   const base::RepeatingClosure progress_cb_;
   EncryptedMediaInitDataCB encrypted_media_init_data_cb_;
 
+  AudioTracksCountChangedCB audio_tracks_count_changed_cb_;
+  std::map<std::string, MediaTracksUpdatedCB> media_tracks_updated_cb_;
+
   // MediaLog for reporting messages and properties to debug content and engine.
   raw_ptr<MediaLog> media_log_;
 
@@ -584,6 +591,9 @@ class MEDIA_EXPORT ChunkDemuxer : public Demuxer {
   StreamParser::FramerateSetCB framerate_set_cb_;
 #endif
 
+  std::map<std::string, unsigned> audio_tracks_count_;
+  unsigned audio_tracks_count_total_{0};
+
   base::TimeDelta duration_ = kNoTimestamp;
 
   // The duration passed to the last SetDuration(). If SetDuration() is never
index 4107d7d..c167fb6 100644 (file)
@@ -584,9 +584,27 @@ std::unique_ptr<Demuxer> DemuxerManager::CreateChunkDemuxer() {
       base::BindPostTaskToCurrentDefault(
           base::BindRepeating(&DemuxerManager::OnEncryptedMediaInitData,
                               weak_factory_.GetWeakPtr())),
+#if BUILDFLAG(IS_TIZEN_TV)
+      base::BindPostTaskToCurrentDefault(
+          base::BindRepeating(&DemuxerManager::OnAudioTracksCountChanged,
+                              weak_factory_.GetWeakPtr())),
+#else
+      base::DoNothing(),
+#endif
       media_log_.get());
 }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+void DemuxerManager::OnAudioTracksCountChanged(unsigned count) {
+  if (client_) {
+    client_->OnAudioTracksCountChanged(count);
+  } else {
+    LOG(ERROR) << __func__
+               << "Audio track count changed, but no client, count: " << count;
+  }
+}
+#endif
+
 #if BUILDFLAG(ENABLE_FFMPEG)
 std::unique_ptr<Demuxer> DemuxerManager::CreateFFmpegDemuxer() {
   DCHECK(data_source_);
index e46d1ef..da513fe 100644 (file)
@@ -75,6 +75,10 @@ class MEDIA_EXPORT DemuxerManager {
 
     virtual bool IsSecurityOriginCryptographic() const = 0;
 
+#if BUILDFLAG(IS_TIZEN_TV)
+    virtual void OnAudioTracksCountChanged(unsigned count) = 0;
+#endif
+
 #if BUILDFLAG(ENABLE_FFMPEG)
     virtual void AddAudioTrack(const std::string& id,
                                const std::string& label,
@@ -203,6 +207,10 @@ class MEDIA_EXPORT DemuxerManager {
   void RestartClientForHLS();
   void FreeResourcesAfterMediaThreadWait(base::OnceClosure cb);
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  void OnAudioTracksCountChanged(unsigned count);
+#endif
+
 #if BUILDFLAG(ENABLE_FFMPEG)
   void OnFFmpegMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks);
 #endif  // BUILDFLAG(ENABLE_FFMPEG)
index cc03a33..cea24a4 100644 (file)
@@ -483,6 +483,13 @@ void PipelineController::SetContentMimeType(const std::string& mime_type) {
     pipeline_->SetContentMimeType(mime_type);
 }
 
+void PipelineController::AudioTracksCountChanged(unsigned count) {
+  if (pipeline_)
+    pipeline_->AudioTracksCountChanged(count);
+  else
+    LOG(ERROR) << "pipeline_ is null";
+}
+
 void PipelineController::SetParentalRatingResult(bool is_pass) {
   if (pipeline_)
     pipeline_->SetParentalRatingResult(is_pass);
index 383d166..f024101 100644 (file)
@@ -165,6 +165,7 @@ class MEDIA_EXPORT PipelineController {
 
 #if BUILDFLAG(IS_TIZEN_TV)
   void SetContentMimeType(const std::string& mime_type);
+  void AudioTracksCountChanged(unsigned count);
   void SetParentalRatingResult(bool is_pass);
   void SetActiveTextTrack(int id, bool is_in_band);
   void SetActiveAudioTrack(int index);
index 8c7ff42..95dff5e 100644 (file)
@@ -392,6 +392,15 @@ void MojoRenderer::SetContentMimeType(const std::string& mime_type) {
     remote_renderer_->SetContentMimeType(mime_type);
 }
 
+void MojoRenderer::AudioTracksCountChanged(unsigned count) {
+  DCHECK(task_runner_->RunsTasksInCurrentSequence());
+
+  if (remote_renderer_.is_bound())
+    remote_renderer_->AudioTracksCountChanged(count);
+  else
+    LOG(ERROR) << "remote_renderer is null";
+}
+
 void MojoRenderer::SetParentalRatingResult(bool is_pass) {
   DCHECK(task_runner_->RunsTasksInCurrentSequence());
 
index 5bf3a50..a4aeba7 100644 (file)
@@ -86,6 +86,7 @@ class MojoRenderer : public Renderer, public mojom::RendererClient {
 #if BUILDFLAG(IS_TIZEN_TV)
   void GetVideoId(GetVideoIdCB cb) override;
   void SetContentMimeType(const std::string& mime_type) override;
+  void AudioTracksCountChanged(unsigned count) override;
   void SetParentalRatingResult(bool is_pass) override;
   void SetActiveTextTrack(int id, bool is_in_band) override;
   void SetActiveAudioTrack(int index) override;
index bff94b6..418df7c 100644 (file)
@@ -88,6 +88,10 @@ void MojoRendererWrapper::SetContentMimeType(const std::string& mime_type) {
     mojo_renderer_->SetContentMimeType(mime_type);
 }
 
+void MojoRendererWrapper::AudioTracksCountChanged(unsigned count) {
+  mojo_renderer_->AudioTracksCountChanged(count);
+}
+
 void MojoRendererWrapper::SetParentalRatingResult(bool is_pass) {
   if (mojo_renderer_)
     mojo_renderer_->SetParentalRatingResult(is_pass);
index 1dc7c14..ae4bbd8 100644 (file)
@@ -54,6 +54,7 @@ class MojoRendererWrapper : public Renderer {
   using GetVideoIdCB = base::OnceCallback<void(int32_t)>;
   void GetVideoId(GetVideoIdCB cb) override;
   void SetContentMimeType(const std::string& mime_type) override;
+  void AudioTracksCountChanged(unsigned count) override;
   void SetParentalRatingResult(bool is_pass) override;
   void SetActiveTextTrack(int id, bool is_in_band) override;
   void SetActiveVideoTrack(int index) override;
index 79a0f93..41fc308 100644 (file)
@@ -99,6 +99,9 @@ interface Renderer {
   GetVideoId()=> (int32 player_id);
 
   [EnableIf=is_tizen_tv]
+  AudioTracksCountChanged(uint32 count);
+
+  [EnableIf=is_tizen_tv]
   SetParentalRatingResult(bool is_pass);
 
   [EnableIf=is_tizen_tv]
index 091f5f7..e2d098d 100644 (file)
@@ -248,6 +248,14 @@ void MojoRendererService::SetContentMimeType(const std::string& mime_type) {
     renderer_->SetContentMimeType(mime_type);
 }
 
+void MojoRendererService::AudioTracksCountChanged(unsigned count) {
+  DVLOG(2) << __func__ << "(" << count << ", " << count << ")";
+  if (renderer_)
+    renderer_->AudioTracksCountChanged(count);
+  else
+    LOG(ERROR) << "renderer_ is null";
+}
+
 void MojoRendererService::SetParentalRatingResult(bool is_pass) {
   DVLOG(3) << __func__;
   if (renderer_)
index 4ddd5a5..c3543bb 100644 (file)
@@ -93,6 +93,7 @@ class MEDIA_MOJO_EXPORT MojoRendererService final : public mojom::Renderer,
 #if BUILDFLAG(IS_TIZEN_TV)
   void GetVideoId(GetVideoIdCallback cb) final;
   void SetContentMimeType(const std::string& mime_type) final;
+  void AudioTracksCountChanged(unsigned count) final;
   void SetParentalRatingResult(bool is_pass) final;
   void SetActiveTextTrack(int id, bool is_in_band) final;
   void SetActiveAudioTrack(int index) final;
index 368db18..b814ec2 100644 (file)
@@ -2278,6 +2278,10 @@ void WebMediaPlayerImpl::OnProgress() {
 }
 
 #if BUILDFLAG(IS_TIZEN_TV)
+void WebMediaPlayerImpl::OnAudioTracksCountChanged(unsigned count) {
+  pipeline_controller_->AudioTracksCountChanged(count);
+}
+
 void WebMediaPlayerImpl::SetActiveTextTrack(int id, bool is_in_band) {
   pipeline_controller_->SetActiveTextTrack(id, is_in_band);
 }
index 78f9847..61a37bc 100644 (file)
@@ -455,6 +455,9 @@ class PLATFORM_EXPORT WebMediaPlayerImpl
   bool IsSecurityOriginCryptographic() const override;
   void UpdateLoadedUrl(const GURL& url) override;
   void DemuxerRequestsSeek(base::TimeDelta seek_time) override;
+#if BUILDFLAG(IS_TIZEN_TV)
+  void OnAudioTracksCountChanged(unsigned count) override;
+#endif
 
 #if BUILDFLAG(ENABLE_FFMPEG)
   void AddAudioTrack(const std::string& id,
index 51abec6..b0a19d4 100644 (file)
@@ -523,6 +523,29 @@ void TizenRendererImpl::UpdateEventData(std::string data) {
       static_cast<void*>(const_cast<char*>(data.c_str())));
 }
 
+void TizenRendererImpl::AudioTracksCountChanged(unsigned count) {
+  if (!blink::IsHbbTV()) {
+    LOG_ID(INFO, player_id_)
+        << "audio tracks count changed, but not hbbtv runtime, ignore ";
+    return;
+  }
+  content::WebContentsDelegate* web_contents_delegate =
+      GetWebContentsDelegate();
+  if (!web_contents_delegate) {
+    LOG_ID(ERROR, player_id_) << "GetWebContentsDelegate failed";
+    return;
+  }
+
+  if (audio_tracks_count_ == count) {
+    LOG_ID(INFO, player_id_)
+        << "audio tracks count same as latest, count " << count;
+    return;
+  }
+
+  audio_tracks_count_ = count;
+  web_contents_delegate->NotifyAudioTracksCount(player_id_, count);
+}
+
 content::WebContentsDelegate* TizenRendererImpl::GetWebContentsDelegate()
     const {
   content::WebContents* web_contents = GetWebContents();
index 6753740..bac5ad6 100644 (file)
@@ -138,6 +138,7 @@ class CONTENT_EXPORT TizenRendererImpl
                            std::string* translated_url = NULL,
                            std::string* drm_info = NULL) override;
   void UpdateCurrentTime(base::TimeDelta current_time) override;
+  void AudioTracksCountChanged(unsigned count) override;
   void OnLivePlaybackComplete() override;
   void GetVideoId(GetVideoIdCB cb) override;
   void SetCallBackFrameSize(const gfx::Size& size) override;
@@ -268,6 +269,7 @@ class CONTENT_EXPORT TizenRendererImpl
   int hw_res_cfg_;
 
   int notify_playback_state_;
+  unsigned audio_tracks_count_ = 0;
   // Stores the mime type.  Required for URL streams which are DASH
   // content, so that we can set it to the media_player_ before calling
   // initialize / prepare.
index 2d979d1..c9d0aa3 100644 (file)
@@ -1056,6 +1056,14 @@ bool MediaPlayerBridgeCapiTV::PlayerPrePlay() {
 
   return true;
 }
+
+void MediaPlayerBridgeCapiTV::AudioTracksCountChanged(unsigned count) {
+  if (GetMediaPlayerClient())
+    GetMediaPlayerClient()->AudioTracksCountChanged(count);
+  else
+    LOG_ID(ERROR, GetPlayerId()) << "media player client is null";
+}
+
 void MediaPlayerBridgeCapiTV::Initialize(VideoRendererSink* sink) {
   player_set_drm_error_cb(player_, DrmErrorCb, this);
   MediaPlayerBridgeCapi::Initialize(sink);
@@ -1489,10 +1497,10 @@ void MediaPlayerBridgeCapiTV::UpdateAudioTrackInfo() {
     memset(audio_track_info[i].alternatives, 0,
            audio_alter_count * sizeof(Alternative_audioStreamInfo));
   }
-#if !defined(EWK_BRINGUP)
+
   if (blink::IsHbbTV())
     AudioTracksCountChanged(audio_alter_count_total);
-#endif
+
   err = player_get_audio_adaptationset_info(player_, audio_track_info);
   if (err != PLAYER_ERROR_NONE) {
     LOG_ID(ERROR, player_id_) << "|player_get_audio_adaptationset_info| failed";
index 08df00e..1feebb9 100644 (file)
@@ -105,6 +105,7 @@ class MEDIA_EXPORT MediaPlayerBridgeCapiTV : public MediaPlayerBridgeCapi {
   void SetDisplayAtPausedState();
   bool CheckLiveStreaming() const;
   bool HBBTVResourceAcquired();
+  void AudioTracksCountChanged(unsigned count);
   bool SetDrmInfo(std::string& drm_info);
   bool SetMediaDRMInfo(const std::string&, const std::string&);
   bool is_preloaded_{false};
index f4ad8ea..b3e4f65 100644 (file)
@@ -71,6 +71,7 @@ class MEDIA_EXPORT MediaPlayerTizenClient {
                                    std::string* translated_url = NULL,
                                    std::string* drm_info = NULL) = 0;
   virtual void UpdateCurrentTime(base::TimeDelta current_time) = 0;
+  virtual void AudioTracksCountChanged(unsigned count) = 0;
   virtual void OnLivePlaybackComplete() = 0;
   virtual content::WebContentsDelegate* GetWebContentsDelegate() const = 0;
 #endif
index 046489d..a837f40 100644 (file)
@@ -3751,6 +3751,15 @@ std::vector<std::string> EWebView::NotifyPlaybackState(int state,
   return data;
 }
 
+void EWebView::NotifyAudioTracksCount(int player_id,
+                                      unsigned audio_tracks_count) {
+  Ewk_Audio_Tracks_Info* audio_tracks_info =
+      ewkAudioTracksInfoCreate(player_id, audio_tracks_count);
+  SmartCallback<EWebViewCallbacks::AudioTracksCount>().call(
+      static_cast<void*>(audio_tracks_info));
+  ewkAudioTracksInfoDelete(audio_tracks_info);
+}
+
 void EWebView::NotifyMediaStateChanged(uint32_t device_type,
                                        uint32_t previous,
                                        uint32_t current) {
index 0d50a4d..5888c68 100644 (file)
@@ -403,6 +403,7 @@ class EWebView {
                                                const char* mime_type);
   void SuspendNetworkLoading();
   void ResumeNetworkLoading();
+  void NotifyAudioTracksCount(int player_id, unsigned audio_tracks_count);
 #endif // IS_TIZEN_TV
   void SetSessionTimeout(uint64_t timeout);
   double GetTextZoomFactor() const;
index 5b2630c..c589c85 100644 (file)
@@ -135,6 +135,7 @@ enum CallbackType {
   UserMediaState,
   PopupMenuShow,
   PopupMenuHide,
+  AudioTracksCount,
   SubtitlePlay,
   SubtitlePause,
   SubtitleStop,
@@ -336,6 +337,7 @@ DECLARE_EWK_VIEW_CALLBACK(DidChagneScrollbarsThumbFocus,
 DECLARE_EWK_VIEW_CALLBACK(UserMediaState, "usermedia,state", void*);
 DECLARE_EWK_VIEW_CALLBACK(PopupMenuShow, "popup,menu,show", void);
 DECLARE_EWK_VIEW_CALLBACK(PopupMenuHide, "popup,menu,hide", void);
+DECLARE_EWK_VIEW_CALLBACK(AudioTracksCount, "notify,audio,tracks,count", void*);
 DECLARE_EWK_VIEW_CALLBACK(SubtitlePlay, "notify,subtitle,play", void*);
 DECLARE_EWK_VIEW_CALLBACK(SubtitlePause, "notify,video,pause", void);
 DECLARE_EWK_VIEW_CALLBACK(SubtitleStop, "notify,subtitle,stop", void);
index 4d40594..bae96fc 100644 (file)
@@ -150,3 +150,34 @@ void ewkMediaPlaybackInfoDelete(Ewk_Media_Playback_Info* data)
   LOG_EWK_API_MOCKUP("Only for Tizen TV.");
 #endif
 }
+
+struct _Ewk_Audio_Tracks_Info {
+  int video_id;
+  unsigned count;
+};
+
+const int ewk_audio_tracks_info_video_id_get(
+    Ewk_Audio_Tracks_Info* data) {
+  EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0);
+  return data->video_id;
+}
+
+const unsigned ewk_audio_tracks_info_count_get(
+    Ewk_Audio_Tracks_Info* data) {
+  EINA_SAFETY_ON_NULL_RETURN_VAL(data, 0);
+  return data->count;
+}
+
+Ewk_Audio_Tracks_Info* ewkAudioTracksInfoCreate(
+  const int player_id,
+  unsigned audio_tracks_count) {
+  Ewk_Audio_Tracks_Info* audio_tracks_info = new _Ewk_Audio_Tracks_Info;
+  audio_tracks_info->video_id = player_id;
+  audio_tracks_info->count = audio_tracks_count;
+  return audio_tracks_info;
+}
+
+void ewkAudioTracksInfoDelete(Ewk_Audio_Tracks_Info* data) {
+  if (data)
+    delete data;
+}
\ No newline at end of file
index b2317f9..01f2d66 100644 (file)
@@ -888,6 +888,15 @@ void WebContentsDelegateEfl::NotifyPlaybackState(int state,
   }
 }
 
+void WebContentsDelegateEfl::NotifyAudioTracksCount(
+    int player_id,
+    unsigned audio_tracks_count) {
+  if (web_view_)
+    web_view_->NotifyAudioTracksCount(player_id, audio_tracks_count);
+  else
+    LOG(INFO) << "web_view_ is null";
+}
+
 void WebContentsDelegateEfl::OnIsVideoPlayingGet(bool is_playing,
                                                  int callback_id) {
   if (web_view_)
index f1433cd..6803af8 100644 (file)
@@ -91,6 +91,8 @@ class WebContentsDelegateEfl : public WebContentsDelegate {
                            std::string* drm_info) override;
   void NotifyParentalRatingInfo(const std::string& info,
                                 const std::string& url) override;
+  void NotifyAudioTracksCount(int player_id,
+                              unsigned audio_tracks_count) override;
   void WillDraw(int rotation, gfx::Size frame_data_output_size) override;
 #endif
   void UpdateTooltipUnderCursor(const std::u16string& text) override;