Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
Javelin
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Auernig
Javelin
Commits
39e72a4d
Commit
39e72a4d
authored
6 years ago
by
Patrick Auernig
Browse files
Options
Downloads
Patches
Plain Diff
Store RTMP timestamp in Media enum
parent
bca6cfb7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/peer/event.rs
+9
-9
9 additions, 9 deletions
src/peer/event.rs
src/peer/media.rs
+12
-7
12 additions, 7 deletions
src/peer/media.rs
with
21 additions
and
16 deletions
src/peer/event.rs
+
9
−
9
View file @
39e72a4d
...
...
@@ -105,10 +105,10 @@ impl Handler {
self
.metadata_received
(
&
app_name
,
&
metadata
)
?
;
},
VideoDataReceived
{
stream_key
,
data
,
timestamp
,
..
}
=>
{
self
.multimedia_data_received
(
&
stream_key
,
timestamp
,
&
Media
::
H264
(
data
))
?
;
self
.multimedia_data_received
(
&
stream_key
,
&
Media
::
H264
(
timestamp
,
data
))
?
;
},
AudioDataReceived
{
stream_key
,
data
,
timestamp
,
..
}
=>
{
self
.multimedia_data_received
(
&
stream_key
,
timestamp
,
&
Media
::
AAC
(
data
))
?
;
self
.multimedia_data_received
(
&
stream_key
,
&
Media
::
AAC
(
timestamp
,
data
))
?
;
},
PublishStreamFinished
{
app_name
,
stream_key
}
=>
{
self
.publish_stream_finished
(
&
app_name
,
&
stream_key
)
?
;
...
...
@@ -269,7 +269,7 @@ impl Handler {
Ok
(())
}
fn
multimedia_data_received
(
&
mut
self
,
stream_key
:
&
str
,
timestamp
:
RtmpTimestamp
,
media
:
&
Media
)
->
Result
<
()
>
{
fn
multimedia_data_received
(
&
mut
self
,
stream_key
:
&
str
,
media
:
&
Media
)
->
Result
<
()
>
{
// debug!("Received video data for stream with key {}", stream_key);
let
app_name
=
self
.shared
...
...
@@ -281,10 +281,10 @@ impl Handler {
let
mut
streams
=
self
.shared.streams
.write
();
if
let
Some
(
stream
)
=
streams
.get_mut
(
&
app_name
)
{
match
&
media
{
Media
::
AAC
(
ref
data
)
if
media
.is_sequence_header
()
=>
{
Media
::
AAC
(
_
,
ref
data
)
if
media
.is_sequence_header
()
=>
{
stream
.audio_seq_header
=
Some
(
data
.clone
());
},
Media
::
H264
(
ref
data
)
if
media
.is_sequence_header
()
=>
{
Media
::
H264
(
_
,
ref
data
)
if
media
.is_sequence_header
()
=>
{
stream
.video_seq_header
=
Some
(
data
.clone
());
},
_
=>
(),
...
...
@@ -303,14 +303,14 @@ impl Handler {
if
let
Some
(
active_stream
)
=
client
.watched_stream
()
{
let
packet
=
match
&
media
{
Media
::
AAC
(
bytes
)
=>
{
client
.session
.send_audio_data
(
active_stream
,
bytes
.clone
(),
timestamp
,
true
)
?
Media
::
AAC
(
timestamp
,
bytes
)
=>
{
client
.session
.send_audio_data
(
active_stream
,
bytes
.clone
(),
timestamp
.clone
()
,
true
)
?
}
Media
::
H264
(
ref
bytes
)
=>
{
Media
::
H264
(
timestamp
,
ref
bytes
)
=>
{
if
media
.is_keyframe
()
{
client
.received_video_keyframe
=
true
;
}
client
.session
.send_video_data
(
active_stream
,
bytes
.clone
(),
timestamp
,
true
)
?
client
.session
.send_video_data
(
active_stream
,
bytes
.clone
(),
timestamp
.clone
()
,
true
)
?
},
};
...
...
This diff is collapsed.
Click to expand it.
src/peer/media.rs
+
12
−
7
View file @
39e72a4d
// TODO: Move this out of this module
use
std
::
collections
::
HashSet
;
use
bytes
::
Bytes
;
use
rml_rtmp
::
sessions
::
StreamMetadata
;
use
rml_rtmp
::{
sessions
::
StreamMetadata
,
time
::
RtmpTimestamp
,
};
#[derive(Debug,
PartialEq,
Eq)]
#[derive(Debug,
Clone,
PartialEq,
Eq)]
pub
enum
Media
{
AAC
(
Bytes
),
H264
(
Bytes
),
AAC
(
RtmpTimestamp
,
Bytes
),
H264
(
RtmpTimestamp
,
Bytes
),
}
impl
Media
{
pub
fn
is_sequence_header
(
&
self
)
->
bool
{
match
self
{
Media
::
AAC
(
ref
bytes
)
=>
{
Media
::
AAC
(
_
,
ref
bytes
)
=>
{
bytes
.len
()
>=
2
&&
bytes
[
0
]
==
0xaf
&&
bytes
[
1
]
==
0x00
},
Media
::
H264
(
ref
bytes
)
=>
{
Media
::
H264
(
_
,
ref
bytes
)
=>
{
bytes
.len
()
>=
2
&&
bytes
[
0
]
==
0x17
&&
bytes
[
1
]
==
0x00
},
}
...
...
@@ -23,7 +28,7 @@ impl Media {
pub
fn
is_keyframe
(
&
self
)
->
bool
{
match
self
{
Media
::
H264
(
bytes
)
=>
{
Media
::
H264
(
_
,
bytes
)
=>
{
bytes
.len
()
>=
2
&&
bytes
[
0
]
==
0x17
&&
bytes
[
1
]
!=
0x00
}
_
=>
false
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment