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>
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,
kMediaUrlDemuxer,
};
+ using AudioTracksCountChangedCB = base::RepeatingCallback<void(unsigned)>;
Demuxer();
Demuxer(const Demuxer&) = delete;
#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;
#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);
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());
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());
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);
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) {}
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_);
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(
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(
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;
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
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_;
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
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_);
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,
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)
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);
#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);
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());
#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;
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);
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;
GetVideoId()=> (int32 player_id);
[EnableIf=is_tizen_tv]
+ AudioTracksCountChanged(uint32 count);
+
+ [EnableIf=is_tizen_tv]
SetParentalRatingResult(bool is_pass);
[EnableIf=is_tizen_tv]
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_)
#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;
}
#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);
}
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,
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();
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;
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.
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);
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";
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};
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
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) {
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;
UserMediaState,
PopupMenuShow,
PopupMenuHide,
+ AudioTracksCount,
SubtitlePlay,
SubtitlePause,
SubtitleStop,
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);
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
}
}
+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_)
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;