Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
51174cd7
Commit
51174cd7
authored
Dec 23, 2015
by
Steve Lhomme
Committed by
Jean-Baptiste Kempf
Dec 23, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chromecast: move connect/disconnectChromecast in the communication handler
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
82d70b6f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
64 deletions
+59
-64
modules/stream_out/chromecast/cast.cpp
modules/stream_out/chromecast/cast.cpp
+7
-64
modules/stream_out/chromecast/chromecast.h
modules/stream_out/chromecast/chromecast.h
+4
-0
modules/stream_out/chromecast/chromecast_ctrl.cpp
modules/stream_out/chromecast/chromecast_ctrl.cpp
+48
-0
No files found.
modules/stream_out/chromecast/cast.cpp
View file @
51174cd7
...
...
@@ -57,18 +57,12 @@ struct sout_stream_sys_t
delete
p_intf
;
}
vlc_tls_creds_t
*
p_creds
;
vlc_thread_t
chromecastThread
;
sout_stream_t
*
p_out
;
intf_sys_t
*
const
p_intf
;
};
// Media player Chromecast app id
#define APP_ID "CC1AD845" // Default media player
#define CHROMECAST_CONTROL_PORT 8009
#define HTTP_PORT 8010
#define SOUT_CFG_PREFIX "sout-chromecast-"
...
...
@@ -79,8 +73,6 @@ struct sout_stream_sys_t
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
static
void
Clean
(
sout_stream_t
*
p_stream
);
static
int
connectChromecast
(
sout_stream_t
*
p_stream
,
char
*
psz_ipChromecast
);
static
void
disconnectChromecast
(
sout_stream_t
*
p_stream
);
static
void
*
chromecastThread
(
void
*
data
);
...
...
@@ -189,18 +181,18 @@ static int Open(vlc_object_t *p_this)
return
VLC_EGENERIC
;
}
p_
sys
->
p_intf
->
i_sock_fd
=
connectChromecast
(
p_stream
,
psz_ipChromecast
);
p_
intf
->
i_sock_fd
=
p_intf
->
connectChromecast
(
psz_ipChromecast
);
free
(
psz_ipChromecast
);
if
(
p_
sys
->
p_
intf
->
i_sock_fd
<
0
)
if
(
p_intf
->
i_sock_fd
<
0
)
{
msg_Err
(
p_stream
,
"Could not connect the Chromecast"
);
Clean
(
p_stream
);
return
VLC_EGENERIC
;
}
p_
sys
->
p_
intf
->
setConnectionStatus
(
CHROMECAST_TLS_CONNECTED
);
p_intf
->
setConnectionStatus
(
CHROMECAST_TLS_CONNECTED
);
char
psz_localIP
[
NI_MAXNUMERICHOST
];
if
(
net_GetSockAddress
(
p_
sys
->
p_
intf
->
i_sock_fd
,
psz_localIP
,
NULL
))
if
(
net_GetSockAddress
(
p_intf
->
i_sock_fd
,
psz_localIP
,
NULL
))
{
msg_Err
(
p_this
,
"Cannot get local IP address"
);
Clean
(
p_stream
);
...
...
@@ -250,9 +242,9 @@ static int Open(vlc_object_t *p_this)
int
i_ret
=
0
;
const
mtime_t
deadline
=
mdate
()
+
6
*
CLOCK_FREQ
;
vlc_mutex_lock
(
&
p_intf
->
lock
);
while
(
p_
sys
->
p_
intf
->
getConnectionStatus
()
!=
CHROMECAST_MEDIA_LOAD_SENT
)
while
(
p_intf
->
getConnectionStatus
()
!=
CHROMECAST_MEDIA_LOAD_SENT
)
{
i_ret
=
vlc_cond_timedwait
(
&
p_
sys
->
p_
intf
->
loadCommandCond
,
&
p_intf
->
lock
,
deadline
);
i_ret
=
vlc_cond_timedwait
(
&
p_intf
->
loadCommandCond
,
&
p_intf
->
lock
,
deadline
);
if
(
i_ret
==
ETIMEDOUT
)
{
msg_Err
(
p_stream
,
"Timeout reached before sending the media loading command"
);
...
...
@@ -322,61 +314,12 @@ static void Clean(sout_stream_t *p_stream)
sout_StreamChainDelete
(
p_sys
->
p_out
,
p_sys
->
p_out
);
}
disconnectChromecast
(
p_stream
);
p_sys
->
p_intf
->
disconnectChromecast
(
);
delete
p_sys
;
}
/**
* @brief Connect to the Chromecast
* @param p_stream the sout_stream_t structure
* @return the opened socket file descriptor or -1 on error
*/
static
int
connectChromecast
(
sout_stream_t
*
p_stream
,
char
*
psz_ipChromecast
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
int
fd
=
net_ConnectTCP
(
p_stream
,
psz_ipChromecast
,
CHROMECAST_CONTROL_PORT
);
if
(
fd
<
0
)
return
-
1
;
p_sys
->
p_creds
=
vlc_tls_ClientCreate
(
VLC_OBJECT
(
p_stream
));
if
(
p_sys
->
p_creds
==
NULL
)
{
net_Close
(
fd
);
return
-
1
;
}
p_sys
->
p_intf
->
p_tls
=
vlc_tls_ClientSessionCreate
(
p_sys
->
p_creds
,
fd
,
psz_ipChromecast
,
"tcps"
,
NULL
,
NULL
);
if
(
p_sys
->
p_intf
->
p_tls
==
NULL
)
{
vlc_tls_Delete
(
p_sys
->
p_creds
);
return
-
1
;
}
return
fd
;
}
/**
* @brief Disconnect from the Chromecast
*/
static
void
disconnectChromecast
(
sout_stream_t
*
p_stream
)
{
sout_stream_sys_t
*
p_sys
=
p_stream
->
p_sys
;
if
(
p_sys
->
p_intf
->
p_tls
)
{
vlc_tls_SessionDelete
(
p_sys
->
p_intf
->
p_tls
);
vlc_tls_Delete
(
p_sys
->
p_creds
);
p_sys
->
p_intf
->
p_tls
=
NULL
;
p_sys
->
p_intf
->
setConnectionStatus
(
CHROMECAST_DISCONNECTED
);
}
}
/*****************************************************************************
...
...
modules/stream_out/chromecast/chromecast.h
View file @
51174cd7
...
...
@@ -67,6 +67,7 @@ struct intf_sys_t
std
::
string
appTransportId
;
int
i_sock_fd
;
vlc_tls_creds_t
*
p_creds
;
vlc_tls_t
*
p_tls
;
vlc_mutex_t
lock
;
...
...
@@ -95,6 +96,9 @@ struct intf_sys_t
}
}
int
connectChromecast
(
char
*
psz_ipChromecast
);
void
disconnectChromecast
();
void
msgPing
();
void
msgPong
();
void
msgConnect
(
const
std
::
string
&
destinationId
=
DEFAULT_CHOMECAST_RECEIVER
);
...
...
modules/stream_out/chromecast/chromecast_ctrl.cpp
View file @
51174cd7
...
...
@@ -46,6 +46,8 @@
// Media player Chromecast app id
#define APP_ID "CC1AD845" // Default media player aka DEFAULT_MEDIA_RECEIVER_APPLICATION_ID
#define CHROMECAST_CONTROL_PORT 8009
/* deadline regarding pings sent from receiver */
#define PING_WAIT_TIME 6000
#define PING_WAIT_RETRIES 0
...
...
@@ -106,6 +108,52 @@ intf_sys_t::~intf_sys_t()
vlc_mutex_destroy
(
&
lock
);
}
/**
* @brief Connect to the Chromecast
* @param p_stream the sout_stream_t structure
* @return the opened socket file descriptor or -1 on error
*/
int
intf_sys_t
::
connectChromecast
(
char
*
psz_ipChromecast
)
{
int
fd
=
net_ConnectTCP
(
p_stream
,
psz_ipChromecast
,
CHROMECAST_CONTROL_PORT
);
if
(
fd
<
0
)
return
-
1
;
p_creds
=
vlc_tls_ClientCreate
(
VLC_OBJECT
(
p_stream
));
if
(
p_creds
==
NULL
)
{
net_Close
(
fd
);
return
-
1
;
}
p_tls
=
vlc_tls_ClientSessionCreate
(
p_creds
,
fd
,
psz_ipChromecast
,
"tcps"
,
NULL
,
NULL
);
if
(
p_tls
==
NULL
)
{
vlc_tls_Delete
(
p_creds
);
return
-
1
;
}
return
fd
;
}
/**
* @brief Disconnect from the Chromecast
*/
void
intf_sys_t
::
disconnectChromecast
()
{
if
(
p_tls
)
{
vlc_tls_SessionDelete
(
p_tls
);
vlc_tls_Delete
(
p_creds
);
p_tls
=
NULL
;
setConnectionStatus
(
CHROMECAST_DISCONNECTED
);
}
}
/**
* @brief Receive a data packet from the Chromecast
* @param p_stream the sout_stream_t structure
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment