Skip to content

Commit 234ce37

Browse files
committed
Initial patch supporting media element playback
- Added interface for castanets WebMediaPlayer - Added renderer manager for managing WebMediaPlayer objects - Added IPCs Signed-off-by: Venugopal S M <[email protected]>
1 parent 87b4885 commit 234ce37

19 files changed

+1819
-3
lines changed

content/common/BUILD.gn

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ source_set("common") {
395395
"//content/public/common:interfaces",
396396
]
397397

398+
if (enable_castanets) {
399+
sources += [
400+
"media/castanets_media_param_traits.cc",
401+
"media/castanets_media_param_traits.h",
402+
"media/castanets_media_player_messages.h",
403+
]
404+
}
405+
398406
if (is_android && use_seccomp_bpf) {
399407
set_sources_assignment_filter([])
400408
sources += [

content/common/content_message_generator.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,12 @@
125125
#error "Failed to include content/common/media/media_player_messages_android.h"
126126
#endif
127127
#endif // defined(OS_ANDROID)
128+
129+
#if defined(CASTANETS)
130+
#undef CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_MESSAGES_H_
131+
#include "content/common/media/castanets_media_player_messages.h"
132+
#ifndef CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_MESSAGES_H_
133+
#error \
134+
"Failed to include content/common/media/castanets_media_player_messages.h"
135+
#endif
136+
#endif
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2019 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+
#include "content/common/media/castanets_media_param_traits.h"
6+
7+
#include "base/strings/stringprintf.h"
8+
#include "ipc/ipc_message_utils.h"
9+
10+
namespace IPC {
11+
12+
void ParamTraits<media::Ranges<base::TimeDelta>>::Write(
13+
base::Pickle* pickle,
14+
const media::Ranges<base::TimeDelta>& range) {
15+
WriteParam(pickle, static_cast<int>(range.size()));
16+
for (size_t i = 0; i < range.size(); ++i) {
17+
WriteParam(pickle, range.start(i));
18+
WriteParam(pickle, range.end(i));
19+
}
20+
}
21+
22+
bool ParamTraits<media::Ranges<base::TimeDelta>>::Read(
23+
const base::Pickle* pickle,
24+
base::PickleIterator* iter,
25+
media::Ranges<base::TimeDelta>* range) {
26+
int size = 0;
27+
28+
// ReadLength() checks for < 0 itself.
29+
if (!iter->ReadLength(&size))
30+
return false;
31+
for (int i = 0; i < size; i++) {
32+
base::TimeDelta start, end;
33+
if (!ReadParam(pickle, iter, &start) || !ReadParam(pickle, iter, &end))
34+
return false;
35+
range->Add(start, end);
36+
}
37+
return true;
38+
}
39+
40+
void ParamTraits<media::Ranges<base::TimeDelta>>::Log(
41+
const media::Ranges<base::TimeDelta>& pickle,
42+
std::string* str) {
43+
str->append("TimeRanges:[");
44+
for (size_t i = 0u; i < pickle.size(); ++i) {
45+
str->append(base::StringPrintf("{%zu:{%lf,%lf}}, ", i,
46+
pickle.start(i).InSecondsF(),
47+
pickle.end(i).InSecondsF()));
48+
}
49+
str->append("]");
50+
}
51+
52+
} // namespace IPC
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PARAM_TRAITS_H_
2+
#define CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PARAM_TRAITS_H_
3+
4+
#include "base/pickle.h"
5+
#include "content/common/content_export.h"
6+
#include "ipc/ipc_param_traits.h"
7+
#include "media/base/ranges.h"
8+
9+
namespace IPC {
10+
11+
template <>
12+
struct CONTENT_EXPORT ParamTraits<media::Ranges<base::TimeDelta>> {
13+
typedef media::Ranges<base::TimeDelta> param_type;
14+
static void Write(base::Pickle* pickle, const param_type& ptype);
15+
static bool Read(const base::Pickle* pickle,
16+
base::PickleIterator* iter,
17+
param_type* ptype);
18+
static void Log(const param_type& ptype, std::string* str);
19+
};
20+
21+
} // namespace IPC
22+
23+
#endif // CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PARAM_TRAITS_H_
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2019 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 CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_INIT_CONFIG_H_
6+
#define CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_INIT_CONFIG_H_
7+
8+
#include <string>
9+
#include "media/blink/renderer_media_player_interface.h"
10+
#include "url/gurl.h"
11+
12+
namespace content {
13+
14+
struct MediaPlayerInitConfig {
15+
MediaPlayerHostMsg_Initialize_Type type;
16+
GURL url;
17+
std::string mime_type;
18+
int demuxer_client_id;
19+
bool has_encrypted_listener_or_cdm;
20+
};
21+
22+
} // namespace content
23+
24+
#endif // CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_INIT_CONFIG_H_
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
// Copyright 2019 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+
// IPC messages for castanets player.
6+
#ifndef CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_MESSAGES_H_
7+
#define CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_MESSAGES_H_
8+
9+
#include "content/common/media/castanets_media_param_traits.h"
10+
#include "content/common/media/castanets_media_player_init_config.h"
11+
#include "ipc/ipc_message_macros.h"
12+
#include "media/blink/renderer_media_player_interface.h"
13+
#include "ui/gfx/geometry/rect_f.h"
14+
15+
#undef IPC_MESSAGE_EXPORT
16+
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
17+
#define IPC_MESSAGE_START MediaPlayerCastanetsMsgStart
18+
19+
IPC_ENUM_TRAITS(blink::WebMediaPlayer::ReadyState)
20+
IPC_ENUM_TRAITS(blink::WebMediaPlayer::NetworkState)
21+
#if !defined(OS_ANDROID)
22+
IPC_ENUM_TRAITS(MediaPlayerHostMsg_Initialize_Type)
23+
#endif
24+
25+
// Should be same as castanets player.
26+
IPC_STRUCT_TRAITS_BEGIN(content::MediaPlayerInitConfig)
27+
IPC_STRUCT_TRAITS_MEMBER(type)
28+
IPC_STRUCT_TRAITS_MEMBER(url)
29+
IPC_STRUCT_TRAITS_MEMBER(mime_type)
30+
IPC_STRUCT_TRAITS_MEMBER(demuxer_client_id)
31+
IPC_STRUCT_TRAITS_MEMBER(has_encrypted_listener_or_cdm)
32+
IPC_STRUCT_TRAITS_END()
33+
34+
// TODO (sm.venugopal): Rename the IPCs.
35+
// Initialize Efl player.
36+
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_Init,
37+
int /* player_id */,
38+
content::MediaPlayerInitConfig /* config */)
39+
40+
// Requests the player to enter fullscreen.
41+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_EnteredFullscreen,
42+
int /* player_id */)
43+
44+
// Requests the player to exit fullscreen.
45+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_ExitedFullscreen, int /* player_id */)
46+
47+
// Deinitialize Gst player.
48+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_DeInit, int /* player_id */)
49+
50+
// Start playback.
51+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_Play, int /* player_id */)
52+
53+
// Pause playback.
54+
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_Pause,
55+
int /* player_id */,
56+
bool /* is_media_related_action */)
57+
58+
// Suspend media player.
59+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_Suspend, int /* player_id */)
60+
61+
// Resume media player.
62+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_Resume, int /* player_id*/)
63+
64+
// Player was activated by an user or an app.
65+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_Activate, int /* player_id*/)
66+
67+
// Player should deactivate (ex. save power).
68+
IPC_MESSAGE_ROUTED1(MediaPlayerEflHostMsg_Deactivate, int /* player_id*/)
69+
70+
// Set volume.
71+
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_SetVolume,
72+
int /* player_id */,
73+
double /* volume */)
74+
75+
// Set playback rate.
76+
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_SetRate,
77+
int /* player_id */,
78+
double /* rate */)
79+
80+
// Playback duration.
81+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_DurationChanged,
82+
int /* player_id */,
83+
base::TimeDelta /* time */)
84+
85+
// Current duration.
86+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_TimeUpdate,
87+
int /* player_id */,
88+
base::TimeDelta /* time */)
89+
90+
// Pause state.
91+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_PauseStateChanged,
92+
int /* player_id */,
93+
bool /* state */)
94+
95+
// Seek state.
96+
IPC_MESSAGE_ROUTED1(MediaPlayerEflMsg_OnSeekComplete, int /* player_id */)
97+
98+
// Current buffer range.
99+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_BufferUpdate,
100+
int /* player_id */,
101+
int /* buffering_percentage */)
102+
103+
// Playback completed.
104+
IPC_MESSAGE_ROUTED1(MediaPlayerEflMsg_TimeChanged, int /* player_id */)
105+
106+
IPC_MESSAGE_ROUTED1(MediaPlayerEflMsg_PlayerDestroyed, int /* player_id */)
107+
108+
// Ready state change.
109+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_ReadyStateChange,
110+
int /* player_id */,
111+
blink::WebMediaPlayer::ReadyState /* state */)
112+
113+
// Network state change.
114+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_NetworkStateChange,
115+
int /* player_id */,
116+
blink::WebMediaPlayer::NetworkState /* state */)
117+
118+
// Gst media data has changed.
119+
IPC_MESSAGE_ROUTED4(MediaPlayerEflMsg_MediaDataChanged,
120+
int /* player_id */,
121+
int /* width */,
122+
int /* height */,
123+
int /* media */)
124+
125+
// Set geometry.
126+
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_SetGeometry,
127+
int /* player_id */,
128+
gfx::RectF /* position and size */)
129+
// Seek.
130+
IPC_MESSAGE_ROUTED2(MediaPlayerEflHostMsg_Seek,
131+
int /* player_id */,
132+
base::TimeDelta /* time */)
133+
134+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_SeekRequest,
135+
int /* player_id */,
136+
base::TimeDelta /* time_to_seek */)
137+
138+
// Player has begun suspend procedure
139+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_PlayerSuspend,
140+
int /* player_id */,
141+
bool /* is_preempted */)
142+
143+
// Player has resumed
144+
IPC_MESSAGE_ROUTED2(MediaPlayerEflMsg_PlayerResumed,
145+
int /* player_id */,
146+
bool /* is_preempted */)
147+
148+
#endif // CONTENT_COMMON_MEDIA_CASTANETS_MEDIA_PLAYER_MESSAGES_H_

content/renderer/BUILD.gn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,15 @@ target(link_target_type, "renderer") {
625625
"worker_thread_registry.h",
626626
]
627627

628+
if (enable_castanets) {
629+
sources += [
630+
"media/castanets/castanets_renderer_media_player_manager.cc",
631+
"media/castanets/castanets_renderer_media_player_manager.h",
632+
"media/castanets/castanets_webmediaplayer_impl.cc",
633+
"media/castanets/castanets_webmediaplayer_impl.h",
634+
]
635+
}
636+
628637
if (!is_component_build) {
629638
if (is_win && is_official_build) {
630639
split_count = 2 # In certain configurations a full renderer.lib can

0 commit comments

Comments
 (0)