}
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void BrowserMediaPlayerManagerEfl::OnPlatformSurfaceUpdated(
- int player_id,
- int pixmap_id,
- base::TimeDelta timestamp) {
- Send(new MediaPlayerEflMsg_PlatformSurfaceUpdated(
- GetRoutingID(), player_id, pixmap_id, timestamp));
-}
-#endif
-
void BrowserMediaPlayerManagerEfl::OnTimeChanged(int player_id) {
Send(new MediaPlayerEflMsg_TimeChanged(GetRoutingID(), player_id));
}
base::TimeDelta timestamp) override;
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void OnPlatformSurfaceUpdated(int player_id, int pixmap_id,
- base::TimeDelta timestamp) override;
-#endif
-
// Helper function to handle IPC from RenderMediaPlayerMangaerEfl.
virtual void OnPlay(int player_id);
virtual void OnPause(int player_id);
base::TimeDelta /* time stamp */)
#endif
-#if defined(OS_TIZEN)
-IPC_MESSAGE_ROUTED3(MediaPlayerEflMsg_PlatformSurfaceUpdated,
- int /* player_id */,
- int /* pixmap_id */,
- base::TimeDelta /* time stamp */)
-#endif
-
// Seek.
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_Seek,
int /* player_id */,
IPC_MESSAGE_HANDLER(MediaPlayerEflMsg_NewTbmBufferAvailable,
OnNewTbmBufferAvailable)
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- IPC_MESSAGE_HANDLER(MediaPlayerEflMsg_PlatformSurfaceUpdated,
- OnPlatformSurfaceUpdated)
-#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void RendererMediaPlayerManager::OnPlatformSurfaceUpdated(
- int player_id,
- int pixmap_id,
- base::TimeDelta timestamp) {
- WebMediaPlayerEfl* player = GetMediaPlayer(player_id);
- if (player)
- player->OnPlatformSurfaceUpdated(pixmap_id, timestamp);
-}
-#endif
-
WebMediaPlayerEfl* RendererMediaPlayerManager::GetMediaPlayer(
int player_id) {
std::map<int, WebMediaPlayerEfl*>::iterator iter =
base::TimeDelta timestamp);
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void OnPlatformSurfaceUpdated(int player_id, int pixmap_id,
- base::TimeDelta timestamp);
-#endif
WebMediaPlayerEfl* GetMediaPlayer(int player_id);
void OnMediaDataChange(int player_id, int format, int height,
int width, int media);
FrameReady(video_frame);
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void WebMediaPlayerEfl::OnPlatformSurfaceUpdated(
- int pixmap_id,
- base::TimeDelta timestamp) {
- gfx::Size size(gst_width_, gst_height_);
- scoped_refptr<VideoFrame> video_frame = VideoFrame::WrapNativePixmap(
- size, gfx::Rect(size), size, timestamp, pixmap_id);
- FrameReady(video_frame);
-}
-#endif
-
void WebMediaPlayerEfl::FrameReady(
const scoped_refptr<VideoFrame>& frame) {
compositor_task_runner_->PostTask(
base::TimeDelta timestamp);
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void OnPlatformSurfaceUpdated(int pixmap_id, base::TimeDelta timestamp);
-#endif
-
void OnMediaDataChange(int format, int height, int width, int media);
void OnDurationChange(double duration);
void OnTimeUpdate(double current_time);
#include "media/base/efl/media_player_util_efl.h"
#include "ui/gfx/geometry/size.h"
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-#include <gst/video/gstvideosink.h>
-#include <gst/video/videooverlay.h>
-#endif
-
namespace {
// Element name
namespace media {
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-static Eina_Bool NotifyDamageUpdatedCB(void* data, int type, void* event) {
- MediaPlayerBridgeGstreamer* player =
- static_cast<MediaPlayerBridgeGstreamer*>(data);
- if (!player)
- return ECORE_CALLBACK_PASS_ON;
- player->PlatformSurfaceUpdated();
- return ECORE_CALLBACK_PASS_ON;
-}
-
-#if defined(OS_TIZEN_TV)
-static int GetPixmapIdCB(void* data) {
- MediaPlayerBridgeGstreamer* player =
- static_cast<MediaPlayerBridgeGstreamer*>(data);
- return player->GetSurfaceID();
-}
-#endif
-#endif
-
static GstBusSyncReply GstPipelineMessageCB(
GstBus* bus,
GstMessage* message,
is_end_reached_(false),
is_seeking_(false),
seek_duration_(0),
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- pixmap_id_(0),
- efl_pixmap_(NULL),
- m_damage_(0),
- m_damage_handler_(NULL),
-#endif
error_occured_(false) {
if (!gst_is_initialized()) {
if (!gst_init_check(NULL, NULL, 0)) {
NULL);
gst_object_unref(bus);
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- PrepareForVideoSink();
-#else
PrepareForVideoFrame();
-#endif
g_object_set(G_OBJECT(uridecodebinsrc_),
kPropertyDownload, true, kPropertyBufferSize,
audio_sinkpad_ = NULL;
video_sinkpad_ = NULL;
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- if (m_damage_) {
- ecore_x_damage_free(m_damage_);
- m_damage_ = 0;
- }
- if (m_damage_handler_) {
- ecore_event_handler_del(m_damage_handler_);
- m_damage_handler_ = NULL;
- }
- if (efl_pixmap_.get()) {
- efl_pixmap_ = NULL;
- }
-#endif
}
void MediaPlayerBridgeGstreamer::SetVolume(double volume) {
gst_element_set_state(pipeline_, GST_STATE_PLAYING);
break;
}
- case GST_MESSAGE_ELEMENT:
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- if (!IsXWindowHandleSet()) {
- if (message->structure &&
- gst_is_video_overlay_prepare_window_handle_message(message)) {
- XWindowIdPrepared(message);
- }
- }
- break;
-#endif
default: {
LOG(ERROR) << "Unhandled GStreamer message type : "
<< GST_MESSAGE_TYPE_NAME(message);
}
void MediaPlayerBridgeGstreamer::PrerollComplete() {
-#if !defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- if (media_type_ & MEDIA_VIDEO_MASK) {
- GetFrameDetails();
- } else
-#endif
- {
- manager()->OnMediaDataChange(
- GetPlayerId(), static_cast<int>(video_format_),
- height_, width_, media_type_);
- }
+ manager()->OnMediaDataChange(
+ GetPlayerId(), static_cast<int>(video_format_),
+ height_, width_, media_type_);
is_prerolled_ = true;
}
}
GstElement* MediaPlayerBridgeGstreamer::GetVideoSink() {
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- return gst_element_factory_make("xvimagesink", kVideoSink);
-#else
return gst_element_factory_make("appsink", kVideoSink);
-#endif
}
void MediaPlayerBridgeGstreamer::PrepareForVideoFrame() {
this, NULL);
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void MediaPlayerBridgeGstreamer::PrepareForVideoSink() {
- int flags = 0;
- g_object_get(pipeline_, "flags", &flags, NULL);
- flags |= GST_PLAY_FLAG_NATIVE_VIDEO;
- flags &= ~GST_PLAY_FLAG_TEXT;
- g_object_set(pipeline_, "flags", flags, NULL);
-}
-
-void MediaPlayerBridgeGstreamer::XWindowIdPrepared(GstMessage* message) {
- // It is called just once after video src is set.
- const GstStructure* structure = gst_message_get_structure(message);
- gst_structure_get_int(structure, "video-width", &width_);
- gst_structure_get_int(structure, "video-height", &height_);
- SetPixmap();
-}
-
-int MediaPlayerBridgeGstreamer::GetSurfaceID() const {
- return pixmap_id_;
-}
-
-void MediaPlayerBridgeGstreamer::SetPixmap() {
- efl_pixmap_ = gfx::EflPixmap::Create(gfx::EflPixmap::SURFACE,
- gfx::Size(width_, height_));
-
- if (!efl_pixmap_.get()) {
- LOG(ERROR) << "gfx::EflPixmap::Create() failed to create Pixmap";
- return;
- }
-
- pixmap_id_ = efl_pixmap_->GetId();
-#if defined(OS_TIZEN_TV)
- g_object_set(appsink_, "pixmap-id-callback", GetPixmapIdCB, NULL);
- g_object_set(appsink_, "pixmap-id-callback-userdata", this, NULL);
-#else
- gst_x_overlay_set_window_handle(GST_X_OVERLAY(appsink_), pixmap_id_);
-#endif
-
- // Register to get notification from ecore for damage updates.
- m_damage_ = ecore_x_damage_new(pixmap_id_,
- ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES);
- m_damage_handler_ = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY,
- NotifyDamageUpdatedCB, this);
- g_object_set(appsink_, "rotate", DEGREE_0, NULL);
-
- PrerollComplete();
-}
-
-void MediaPlayerBridgeGstreamer::PlatformSurfaceUpdated() {
- gint64 current_time = 0;
- GstFormat format = GST_FORMAT_TIME;
- gst_element_query_position(pipeline_, format, ¤t_time);
- base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
- current_time / base::Time::kNanosecondsPerMicrosecond);
- manager()->OnPlatformSurfaceUpdated(GetPlayerId(), pixmap_id_, timestamp);
-}
-#endif
-
void MediaPlayerBridgeGstreamer::OnNewPadAdded(GstPad* new_pad) {
GstCaps* new_pad_caps = gst_pad_query_caps(new_pad, NULL);
const gchar* new_pad_type =
#include "media/base/video_frame.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-#include "ui/gl/efl_pixmap.h"
-
-#include <Ecore.h>
-#include "ecore_x_wayland_wrapper.h"
-#endif
-
namespace media {
class MEDIA_EXPORT MediaPlayerBridgeGstreamer
void SampleReady(GstSample* buffer);
void PrerollComplete();
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void PlatformSurfaceUpdated();
- int GetSurfaceID() const;
-#endif
-
void OnNewPadAdded(GstPad* pad);
void OnNoMorePadsAvailable();
GstElement* GetVideoSink();
void PrepareForVideoFrame();
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void PrepareForVideoSink();
- void XWindowIdPrepared(GstMessage* message);
- bool IsXWindowHandleSet() {return pixmap_id_ ? true : false ;}
- void SetPixmap();
-#endif
-
private:
const scoped_refptr<base::SingleThreadTaskRunner> main_loop_;
GstElement* pipeline_;
bool is_seeking_;
double seek_duration_;
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- int pixmap_id_;
- scoped_refptr<gfx::EflPixmap> efl_pixmap_;
- Ecore_X_Damage m_damage_;
- Ecore_Event_Handler* m_damage_handler_;
-#endif
-
bool error_occured_;
base::RepeatingTimer current_time_update_timer_;
int player_id, gfx::TbmBufferHandle tbm_handle,
base::TimeDelta timestamp) = 0;
#endif
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- virtual void OnPlatformSurfaceUpdated(int player_id, int pixmap_id,
- base::TimeDelta timestamp) = 0;
-#endif
virtual void OnInitComplete(int player_id, bool success) = 0;
virtual void OnResumeComplete(int player_id) = 0;
virtual void OnSuspendComplete(int player_id) = 0;
GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10)
} GstPlayFlags;
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-typedef enum {
- DEGREE_0, // No rotate.
- DEGREE_90, // Rotate 90 degree count clockwise.
- DEGREE_180, // Rotate 180 degree count clockwise.
- DEGREE_270 // Rotate 270 degree count clockwise.
-} RotateAngle;
-#endif
-
typedef enum {
GST_AUTOPLUG_SELECT_TRY,
GST_AUTOPLUG_SELECT_EXPOSE,
{media::kUnknownVideoCodec, NULL}
};
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-// Generating Unique integer for given height / width.
-int GetUniqueKey(int x, int y) {
- return ((x << 16) | y);
-}
-#endif
-
} // namespace
namespace media {
return GST_BUS_DROP;
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-static Eina_Bool NotifyDamageUpdatedCB(
- void* user_data,
- int type,
- void* event) {
- MediaSourcePlayerGstreamer* player =
- static_cast<MediaSourcePlayerGstreamer*>(user_data);
- if (!player || player->IsPlayerDestructing())
- return ECORE_CALLBACK_PASS_ON;
- player->PlatformSurfaceUpdated();
- return ECORE_CALLBACK_PASS_ON;
-}
-
-#if defined(OS_TIZEN_TV)
-static int GetPixmapIdCB(void* user_data) {
- MediaSourcePlayerGstreamer* player =
- static_cast<MediaSourcePlayerGstreamer*>(user_data);
- return player->GetSurfaceID();
-}
-#endif
-#endif
-
static void OnGstStartVideoFeedCB(
GstAppSrc* pipeline,
guint size,
player->OnStopDemuxedData(media::DemuxerStream::AUDIO);
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-static void OnVideoSinkCapsChangedCB(
- GObject* gobject,
- GParamSpec* gparamspec,
- void* user_data) {
- MediaSourcePlayerGstreamer* player =
- static_cast<MediaSourcePlayerGstreamer*>(user_data);
- if (!player || player->IsPlayerDestructing())
- return;
- player->OnVideoConfigsChanged();
-}
-#endif
-
MediaPlayerEfl* MediaPlayerEfl::CreatePlayer(
int player_id, content::BrowserDemuxerEfl* demuxer,
int demuxer_id, MediaPlayerManager* manager) {
task_runner_(base::ThreadTaskRunnerHandle::Get()),
playing_(false),
weak_this_(this),
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- pixmap_id_(0),
- efl_pixmap_(NULL),
- m_damage_(0),
- m_damage_handler_(0),
-#endif
is_xwindow_handle_set_(false),
pipeline_(NULL),
video_appsrc_(NULL),
demuxer_->Initialize(this);
audio_buffer_queue_.clear();
video_buffer_queue_.clear();
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- efl_pixmaps_map_.clear();
-#endif
}
void MediaSourcePlayerGstreamer::Initialize() {
gst_object_unref(pipeline_);
pipeline_ = NULL;
}
-
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- UnregisterDamageHandler();
- efl_pixmaps_map_.clear();
-#endif
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void MediaSourcePlayerGstreamer::UnregisterDamageHandler() {
- if (m_damage_) {
- ecore_x_damage_free(m_damage_);
- m_damage_ = 0;
- }
- if (m_damage_handler_) {
- ecore_event_handler_del(m_damage_handler_);
- m_damage_handler_ = 0;
- }
-}
-#endif
-
void MediaSourcePlayerGstreamer::SetVolume(double volume) {
if (audio_volume_)
g_object_set(G_OBJECT(audio_volume_), "volume", volume, NULL);
HandleError(blink::WebMediaPlayer::NetworkStateDecodeError);
return;
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- PrepareForVideoSink();
- CreatePixmap();
-#else
PrepareForVideoFrame();
-#endif
+
if (video_sink_ && !gst_bin_add(GST_BIN(pipeline_), video_sink_)) {
gst_object_unref(video_sink_);
HandleError(blink::WebMediaPlayer::NetworkStateDecodeError);
}
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void MediaSourcePlayerGstreamer::PrepareForVideoSink() {
- video_sink_ = gst_element_factory_make("xvimagesink", "sink");
- DCHECK(video_sink_ != NULL) << "Failed to initialize xvimagesink.";
- if (video_sink_ != NULL) {
- GstPad* video_sink_pad = gst_element_get_static_pad(video_sink_, "sink");
- if (!video_sink_pad) {
- LOG(ERROR) << "GStreamer sink could not be obtained";
- HandleError(blink::WebMediaPlayer::NetworkStateDecodeError);
- return;
- }
- g_signal_connect(video_sink_pad, "notify::caps",
- G_CALLBACK(OnVideoSinkCapsChangedCB), this);
- gst_object_unref(video_sink_pad);
- }
-}
-#endif
-
void MediaSourcePlayerGstreamer::PrepareForVideoFrame() {
is_xwindow_handle_set_ = true;
video_sink_ = gst_element_factory_make("appsink", "sink");
gst_sample_unref(sample);
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void MediaSourcePlayerGstreamer::XWindowIdPrepared(GstMessage* message) {
- const GstStructure* structure = gst_message_get_structure(message);
-
- gst_structure_get_int(structure, "video-width", &width_);
- gst_structure_get_int(structure, "video-height", &height_);
- SetPixmap();
- manager()->OnMediaDataChange(GetPlayerId(), video_format_, height_,
- width_, media_type_);
-}
-
-void MediaSourcePlayerGstreamer::PlatformSurfaceUpdated() {
- gint64 current_time = 0;
- GstFormat format = GST_FORMAT_TIME;
- gst_element_query_position(pipeline_, format, ¤t_time);
- base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
- current_time / base::Time::kNanosecondsPerMicrosecond);
- manager()->OnPlatformSurfaceUpdated(GetPlayerId(), pixmap_id_, timestamp);
-}
-
-int MediaSourcePlayerGstreamer::GetSurfaceID() const {
- return pixmap_id_;
-}
-
-void MediaSourcePlayerGstreamer::SetPixmap() {
-#if defined(OS_TIZEN_TV)
- // Using below statements on mobile to set pixmap was causing two issue.
- // 1. Video size was different than the required one whenever configaration
- // changed
- // 2. Sometime black screen was appearing, while video was playing.
- // Hence for mobile keeping implementation which uses
- // |gst_x_overlay_set_window_handle|to sep Pixmap.
- g_object_set(video_sink_, "pixmap-id-callback", GetPixmapIdCB, NULL);
- g_object_set(video_sink_, "pixmap-id-callback-userdata", this, NULL);
-#else
- gst_x_overlay_set_window_handle(GST_X_OVERLAY(video_sink_), pixmap_id_);
-#endif
- m_damage_ = ecore_x_damage_new(pixmap_id_,
- ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES);
- m_damage_handler_ = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY,
- NotifyDamageUpdatedCB, this);
- g_object_set(video_sink_, "rotate", 0, NULL);
- is_xwindow_handle_set_ = true;
-}
-
-void MediaSourcePlayerGstreamer::OnVideoConfigsChanged() {
- if (!pipeline_ || error_occured_)
- return;
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&MediaSourcePlayerGstreamer::VideoConfigsChanged,
- base::Unretained(this)));
-}
-
-void MediaSourcePlayerGstreamer::VideoConfigsChanged() {
- if (!pipeline_ || IsPlayerDestructing() || error_occured_)
- return;
-
- GstPad* video_sink_pad = gst_element_get_static_pad(video_sink_, "sink");
- GstCaps* caps = gst_pad_get_current_caps(GST_PAD(video_sink_pad));
- if (!caps) {
- LOG(ERROR) << "Cannot get CAPS!";
- gst_object_unref(video_sink_pad);
- return;
- }
-
- GstVideoInfo info;
- gst_video_info_init(&info);
- if (!gst_video_info_from_caps(&info, caps)) {
- LOG(ERROR) << "Cannot get information from CAPS!";
- gst_caps_unref(caps);
- gst_object_unref(video_sink_pad);
- return;
- }
-
- if ((width_ != info.width) || (height_ != info.height)) {
- LOG(ERROR) << "Demuxer Video Configs and Gstreamer Video Configs doesn't"
- <<" match.From Demuxer : width : " << width_
- << " and height :" << height_
- << " | From Gstreamer width : " << info.width
- << " and Height : " << info.height;
- width_ = info.width;
- height_ = info.height;
- UnregisterDamageHandler();
- CreatePixmap();
- SetPixmap();
- manager()->OnMediaDataChange(
- GetPlayerId(), video_format_, height_, width_, media_type_);
- }
- gst_caps_unref(caps);
- gst_object_unref(video_sink_pad);
-}
-
-void MediaSourcePlayerGstreamer::CreatePixmap() {
- bool is_create_new = efl_pixmaps_map_.empty();
- int int_wh = GetUniqueKey(width_, height_);
-
- if (!is_create_new) {
- EflPixmapMap::iterator it = efl_pixmaps_map_.find(int_wh);
- if (it != efl_pixmaps_map_.end()) {
- is_create_new = false;
- efl_pixmap_ = it->second;
- pixmap_id_ = efl_pixmap_->GetId();
- } else {
- is_create_new = true;
- }
- }
-
- if (is_create_new) {
- efl_pixmap_ = gfx::EflPixmap::Create(gfx::EflPixmap::SURFACE,
- gfx::Size(width_, height_));
- if (!efl_pixmap_.get()) {
- LOG(ERROR) << "gfx::EflPixmap::Create() failed to create Pixmap";
- return;
- }
- pixmap_id_ = efl_pixmap_->GetId();
- efl_pixmaps_map_[int_wh] = efl_pixmap_;
- }
-}
-#endif
-
void MediaSourcePlayerGstreamer::OnDemuxerDurationChanged(
base::TimeDelta duration) {
duration_ = duration.InSecondsF();
}
break;
}
- case GST_MESSAGE_ELEMENT:
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- if (!IsXWindowHandleSet() &&
- gst_is_video_overlay_prepare_window_handle_message(message)) {
- XWindowIdPrepared(message);
- }
- break;
-#endif
default:
break;
}
#include "media/base/decoder_buffer.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-#include <map>
-
-#include "ui/gl/efl_pixmap.h"
-#endif
-
namespace {
struct AudioCodecGstElementsMapping {
media::AudioCodec codec;
GstSample* PullSample();
void OnNewFrameAvailable(GstSample* sample);
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void PlatformSurfaceUpdated();
- void OnVideoConfigsChanged();
- int GetSurfaceID() const;
-#endif
-
void OnReadDemuxedData(media::DemuxerStream::Type type);
void OnStopDemuxedData(media::DemuxerStream::Type type);
private:
void PrepareForVideoFrame();
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void PrepareForVideoSink();
- void VideoConfigsChanged();
- void CreatePixmap();
- void SetPixmap();
- bool IsXWindowHandleSet() { return is_xwindow_handle_set_;}
- void XWindowIdPrepared(GstMessage* message);
- void UnregisterDamageHandler();
-#endif
void BufferMetaDataAvailable(const media::DemuxedBufferMetaData& meta_data);
void ReadDemuxedData(media::DemuxerStream::Type type);
// Weak pointer passed to media decoder jobs for callbacks.
base::WeakPtrFactory<MediaSourcePlayerGstreamer> weak_this_;
- // To support Vedio Sink (pixmap).
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- int pixmap_id_;
- scoped_refptr<gfx::EflPixmap> efl_pixmap_;
- Ecore_X_Damage m_damage_;
- Ecore_Event_Handler* m_damage_handler_;
- typedef std::map<int, scoped_refptr<gfx::EflPixmap> > EflPixmapMap;
- EflPixmapMap efl_pixmaps_map_;
-#endif
-
// Will allow to listen to |prepare-xid| message only once.
bool is_xwindow_handle_set_;
#include "media/base/tizen/media_player_bridge_capi.h"
+#include <player_internal.h>
+
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
+#include "build/tizen_version.h"
#include "media/base/efl/media_player_manager_efl.h"
#include "media/base/efl/media_player_util_efl.h"
#include "third_party/libyuv/include/libyuv/planar_functions.h"
#include "ui/gfx/geometry/size.h"
-#include "build/tizen_version.h"
-#if defined(USE_LEGACY_PLAYER_CAPI)
-#include <player_product.h>
-#else
-#include <player_internal.h>
-#endif
-
namespace {
// Update duration every 100ms.
player->OnPlayerPrepared();
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-static Eina_Bool NotifyDamageUpdatedCb(void* data, int type, void* event) {
- media::MediaPlayerBridgeCapi* player =
- static_cast<media::MediaPlayerBridgeCapi*>(data);
- if (!player)
- return ECORE_CALLBACK_PASS_ON;
-
- player->PlatformSurfaceUpdated();
- return ECORE_CALLBACK_PASS_ON;
-}
-
-// Called by player_set_x11_display_pixmap()
-static unsigned int PixmapBufferReadyCb(void* data) {
- media::MediaPlayerBridgeCapi* player =
- static_cast<media::MediaPlayerBridgeCapi*>(data);
- if (!player || player->IsPlayerDestructing())
- return -1;
-
- return player->GetPixmapID();
-}
-#else
static void MediaPacketDecodedCb(media_packet_h packet, void* data) {
DCHECK(data);
if (!packet) {
player->OnMediaPacketUpdated(packet_holder.Pass());
}
-#endif
// Called by player_set_completed_cb()
static void PlaybackCompleteCb(void* data) {
MediaPlayerManager* manager_in,
const std::string& user_agent)
: MediaPlayerEfl(player_id, manager_in),
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- efl_pixmap_(0),
- damage_(0),
- damage_handler_(NULL),
-#endif
task_runner_(base::ThreadTaskRunnerHandle::Get()),
player_(NULL),
url_(url),
user_agent_.length()) != PLAYER_ERROR_NONE)
LOG(ERROR) << "Unable to set streaming user agent.";
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- ret = player_set_x11_display_pixmap(player_, PixmapBufferReadyCb, this);
- if (ret != PLAYER_ERROR_NONE) {
- HandleError(ret, "player_set_x11_display_pixmap");
- RunCompleteCB(false, FROM_HERE);
- return;
- }
-#else
ret = player_set_media_packet_video_frame_decoded_cb(
player_, MediaPacketDecodedCb, this);
if (ret != PLAYER_ERROR_NONE) {
RunCompleteCB(false, FROM_HERE);
return;
}
-#endif
player_set_completed_cb(player_, PlaybackCompleteCb, this);
player_set_buffering_cb(player_, ChangedBufferingStatusCb, this);
player_set_interrupted_cb(player_, InterruptCb, this);
player_set_error_cb(player_, ErrorCb, this);
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-#if defined(USE_LEGACY_PLAYER_CAPI)
- player_set_x11_display_visible (player_, true);
-#else
- player_set_display_visible (player_, true);
-#endif
-#endif
-
ret = player_prepare_async(player_, PlayerPreparedCb, this);
if (ret != PLAYER_ERROR_NONE) {
HandleError(ret, "player_prepare_async");
player_unset_interrupted_cb(player_);
player_unset_error_cb(player_);
player_unset_buffering_cb(player_);
-#if !defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
player_unset_media_packet_video_frame_decoded_cb(player_);
-#endif
if (GetPlayerState() > PLAYER_STATE_READY &&
player_stop(player_) != PLAYER_ERROR_NONE) {
manager()->OnSuspendComplete(GetPlayerId());
}
}
-
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- if (damage_) {
- ecore_x_damage_free(damage_);
- damage_ = 0;
- }
- if (damage_handler_) {
- ecore_event_handler_del(damage_handler_);
- damage_handler_ = NULL;
- }
- if (efl_pixmap_.get()) {
- efl_pixmap_ = NULL;
- }
-#endif
}
void MediaPlayerBridgeCapi::Play() {
if (sample_rate > 0)
media_type_ |= MEDIA_AUDIO_MASK;
-// FIXME : player_get_video_size() always returns zero if using media_packet.
-// Remove it once the platform issue is resolved.
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- err = player_get_video_size(player_, &player_width_, &player_height_);
- if (err != PLAYER_ERROR_NONE) {
- HandleError(err, "player_get_video_size");
- RunCompleteCB(false, FROM_HERE);
- return;
- }
-#endif
-
// Video stream is present if both video width and height are valid.
if (player_width_ > 0 && player_height_ > 0)
media_type_ |= MEDIA_VIDEO_MASK;
return;
}
UpdateDuration();
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- SetPixmap();
-#endif
manager()->OnReadyStateChange(
GetPlayerId(), blink::WebMediaPlayer::ReadyStateHaveEnoughData);
manager()->OnNetworkStateChange(
RunCompleteCB(true, FROM_HERE);
}
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-void MediaPlayerBridgeCapi::PlatformSurfaceUpdated() {
- int postion = 0;
-#if defined(USE_LEGACY_PLAYER_CAPI)
- player_get_position(player_, &postion);
-#else
- player_get_play_position(player_, &postion);
-#endif
- base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds(postion);
- manager()->OnPlatformSurfaceUpdated(GetPlayerId(), efl_pixmap_->GetId(),
- timestamp);
-}
-
-void MediaPlayerBridgeCapi::SetPixmap() {
- if ((media_type_ & MEDIA_VIDEO_MASK) && !efl_pixmap_.get()) {
- efl_pixmap_ = gfx::EflPixmap::Create(
- gfx::EflPixmap::SURFACE, gfx::Size(player_width_, player_height_));
- if (!efl_pixmap_.get()) {
- HandleError(0, "gfx::EflPixmap::Create");
- RunCompleteCB(false, FROM_HERE);
- return;
- }
-
- //Register to get notification from ecore for damage updates.
- damage_ = ecore_x_damage_new(efl_pixmap_->GetId(),
- ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES);
- damage_handler_ = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY,
- NotifyDamageUpdatedCb, this);
- }
-}
-#else
void MediaPlayerBridgeCapi::MediaPacketUpdated(
scoped_ptr<MediaPacketHolder> packet) {
tbm_surface_h surface;
shared_memory_size, timestamp);
#endif
}
-#endif
void MediaPlayerBridgeCapi::HandleBufferingStatus(int percent) {
if (is_paused_ || is_seeking_)
}
}
-#if !defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
void MediaPlayerBridgeCapi::OnMediaPacketUpdated(
scoped_ptr<MediaPacketHolder> packet) {
task_runner_->PostTask(
FROM_HERE, base::Bind(&MediaPlayerBridgeCapi::MediaPacketUpdated,
weak_factory_.GetWeakPtr(), base::Passed(&packet)));
}
-#endif
void MediaPlayerBridgeCapi::OnPlaybackCompleteUpdate() {
task_runner_->PostTask(
#include "media/base/efl/media_player_efl.h"
#include "media/base/video_frame.h"
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
-#include <Ecore.h>
-
-#include "ecore_x_wayland_wrapper.h"
-#include "ui/gl/efl_pixmap.h"
-#else
#include <media_packet.h>
#include <tbm_surface.h>
-#endif
namespace media {
void ExecuteDelayedPlayerState();
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- void SetPixmap();
- int GetPixmapID() const {return efl_pixmap_->GetId();}
- void PlatformSurfaceUpdated();
-#else
void OnMediaPacketUpdated(scoped_ptr<MediaPacketHolder> packet);
void SendFrame(tbm_surface_h surface);
-#endif
void OnPlaybackCompleteUpdate();
void OnSeekCompleteUpdate();
void UpdateSeekState(bool state);
void UpdateDuration();
-#if !defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
void MediaPacketUpdated(scoped_ptr<MediaPacketHolder> packet);
-#endif
void PlaybackCompleteUpdate();
void SeekCompleteUpdate();
void PlayerPrepared();
player_state_e GetPlayerState();
private:
-#if defined(TIZEN_MULTIMEDIA_PIXMAP_SUPPORT)
- scoped_refptr<gfx::EflPixmap> efl_pixmap_;
- Ecore_X_Damage damage_;
- Ecore_Event_Handler* damage_handler_;
-#else
scoped_ptr<MediaPacketHolder> previous_packet_;
-#endif
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
}
#endif // USE_LEGACY_PLAYER_CAPI
-#ifndef TIZEN_VIDEO_HOLE
static void OnMediaPktDecoded(media_packet_h packet, void* data) {
if (!packet) {
LOG(ERROR) << "media_packet handle is null";
}
player->OnMediaPacketUpdated(packet);
}
-#endif
void OnPlaybackCompleteCB(void* user_data) {
LOG(INFO) << "On playback complete Call back";
GetPlayerId(), foreign_memory_handle, shared_memory_size, timestamp);
#endif
}
-#endif // TIZEN_VIDEO_HOLE
+#endif // defined(TIZEN_VIDEO_HOLE)
void MediaSourcePlayerCapi::SetVolume(double volume) {
if (GetPlayerState() <= PLAYER_STATE_IDLE)
}
}
- // FIXME(Venu): Need to check where is the exact place for this code.
+ // TODO(Venu): Need to check where is the exact place for this code.
// For make it work added this below code
manager()->OnReadyStateChange(
GetPlayerId(), blink::WebMediaPlayer::ReadyStateHaveEnoughData);
#include "media/base/decoder_buffer.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
-#ifndef TIZEN_VIDEO_HOLE
#include <tbm_surface.h>
-#endif
namespace media {
private:
void PrepareComplete();
void BufferMetaDataAvailable(const media::DemuxedBufferMetaData& meta_data);
-#ifndef TIZEN_VIDEO_HOLE
void MediaPacketUpdated(media_packet_h packet);
void SendFrame(tbm_surface_h surface);
-#endif
void ReadDemuxedData(media::DemuxerStream::Type type);
void SaveDecoderBuffer(
base::SharedMemoryHandle foreign_memory_handle,