Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Steve Lhomme
VLC
Commits
4a6bd2bd
Commit
4a6bd2bd
authored
Feb 26, 2017
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chromecast: use vlc_tls_Read() and simplify
No (dys)functional changes.
parent
18e0428b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
33 deletions
+11
-33
modules/stream_out/chromecast/chromecast_communication.cpp
modules/stream_out/chromecast/chromecast_communication.cpp
+11
-33
No files found.
modules/stream_out/chromecast/chromecast_communication.cpp
View file @
4a6bd2bd
...
...
@@ -124,7 +124,6 @@ void ChromecastCommunication::buildMessage(const std::string & namespace_,
*/
ssize_t
ChromecastCommunication
::
recvPacket
(
uint8_t
*
p_data
)
{
uint32_t
i_received
=
0
;
ssize_t
i_payloadSize
=
-
1
;
struct
pollfd
ufd
[
1
];
ufd
[
0
].
fd
=
m_sock_fd
;
...
...
@@ -144,7 +143,6 @@ ssize_t ChromecastCommunication::recvPacket( uint8_t *p_data )
if
(
val
==
0
)
return
0
;
int
i_ret
=
0
;
if
(
ufd
[
0
].
revents
&
POLLIN
)
{
/* we have received stuff */
...
...
@@ -153,14 +151,10 @@ ssize_t ChromecastCommunication::recvPacket( uint8_t *p_data )
* +------------------------------------+------------------------------+
* | Payload size (uint32_t big endian) | Payload data |
* +------------------------------------+------------------------------+ */
while
(
i_received
<
PACKET_HEADER_LEN
)
{
// We receive the header.
i_ret
=
tls_Recv
(
m_tls
,
p_data
+
i_received
,
PACKET_HEADER_LEN
-
i_received
);
if
(
i_ret
<=
0
)
return
-
1
;
i_received
+=
i_ret
;
}
// We receive the header.
ssize_t
i_ret
=
vlc_tls_Read
(
m_tls
,
p_data
,
PACKET_HEADER_LEN
,
true
);
if
(
i_ret
<
PACKET_HEADER_LEN
)
return
-
1
;
// We receive the payload.
...
...
@@ -171,34 +165,18 @@ ssize_t ChromecastCommunication::recvPacket( uint8_t *p_data )
if
(
i_payloadSize
>
i_maxPayloadSize
)
{
// Error case: the packet sent by the Chromecast is too long: we drop it.
msg_Err
(
m_module
,
"Packet too long: droping its data"
);
uint32_t
i_size
=
i_payloadSize
-
(
i_received
-
PACKET_HEADER_LEN
);
if
(
i_size
>
i_maxPayloadSize
)
i_size
=
i_maxPayloadSize
;
i_ret
=
tls_Recv
(
m_tls
,
p_data
+
PACKET_HEADER_LEN
,
i_size
);
if
(
i_ret
<=
0
)
return
-
1
;
i_received
+=
i_ret
;
msg_Err
(
m_module
,
"Packet too long: dropping its data"
);
if
(
i_received
<
i_payloadSize
+
PACKET_HEADER_LEN
)
return
i_ret
;
return
-
1
;
i_ret
=
vlc_tls_Read
(
m_tls
,
p_data
+
PACKET_HEADER_LEN
,
i_maxPayloadSize
,
false
);
return
i_ret
?
i_ret
:
-
1
;
}
// Normal case
i_ret
=
tls_Re
cv
(
m_tls
,
p_data
+
i_received
,
i_payloadSize
-
(
i_received
-
PACKET_HEADER_LEN
)
);
if
(
i_ret
<
=
0
)
i_ret
=
vlc_
tls_Re
ad
(
m_tls
,
p_data
+
PACKET_HEADER_LEN
,
i_payloadSize
,
false
);
if
(
i_ret
<
i_payloadSize
)
return
-
1
;
i_received
+=
i_ret
;
if
(
i_received
<
i_payloadSize
+
PACKET_HEADER_LEN
)
return
-
1
;
assert
(
i_received
==
i_payloadSize
+
PACKET_HEADER_LEN
);
}
return
i_payloadSize
;
}
...
...
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