Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gst-plugins-good
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
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
Jakub Adam
gst-plugins-good
Commits
77e26375
Commit
77e26375
authored
Mar 18, 2009
by
Sebastian Dröge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp: Use GLib functions for encoding/decoding base64
parent
8cf0e9ff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
187 deletions
+19
-187
gst/rtp/gstrtph264depay.c
gst/rtp/gstrtph264depay.c
+10
-51
gst/rtp/gstrtph264pay.c
gst/rtp/gstrtph264pay.c
+4
-32
gst/rtp/gstrtptheoradepay.c
gst/rtp/gstrtptheoradepay.c
+3
-51
gst/rtp/gstrtptheorapay.c
gst/rtp/gstrtptheorapay.c
+1
-26
gst/rtp/gstrtpvorbispay.c
gst/rtp/gstrtpvorbispay.c
+1
-27
No files found.
gst/rtp/gstrtph264depay.c
View file @
77e26375
...
...
@@ -202,54 +202,6 @@ gst_rtp_h264_depay_get_property (GObject * object, guint prop_id,
}
}
static
const
guint8
a2bin
[
256
]
=
{
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
62
,
64
,
64
,
64
,
63
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
64
,
64
,
64
,
64
,
64
,
64
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
};
static
guint
decode_base64
(
gchar
*
in
,
guint8
*
out
)
{
guint8
v1
,
v2
;
guint
len
=
0
;
v1
=
a2bin
[(
gint
)
*
in
];
while
(
v1
<=
63
)
{
/* read 4 bytes, write 3 bytes, invalid base64 are zeroes */
v2
=
a2bin
[(
gint
)
*
++
in
];
*
out
++
=
(
v1
<<
2
)
|
((
v2
&
0x3f
)
>>
4
);
v1
=
(
v2
>
63
?
64
:
a2bin
[(
gint
)
*
++
in
]);
*
out
++
=
(
v2
<<
4
)
|
((
v1
&
0x3f
)
>>
2
);
v2
=
(
v1
>
63
?
64
:
a2bin
[(
gint
)
*
++
in
]);
*
out
++
=
(
v1
<<
6
)
|
(
v2
&
0x3f
);
v1
=
(
v2
>
63
?
64
:
a2bin
[(
gint
)
*
++
in
]);
len
+=
3
;
}
/* move to '\0' */
while
(
*
in
!=
'\0'
)
in
++
;
/* subtract padding */
while
(
len
>
0
&&
*--
in
==
'='
)
len
--
;
return
len
;
}
static
gboolean
gst_rtp_h264_depay_setcaps
(
GstBaseRTPDepayload
*
depayload
,
GstCaps
*
caps
)
{
...
...
@@ -296,10 +248,13 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
b64
=
GST_BUFFER_DATA
(
codec_data
);
total
=
0
;
for
(
i
=
0
;
params
[
i
];
i
++
)
{
guint
save
=
0
;
gint
state
=
0
;
GST_DEBUG_OBJECT
(
depayload
,
"decoding param %d"
,
i
);
memcpy
(
b64
,
sync_bytes
,
sizeof
(
sync_bytes
));
b64
+=
sizeof
(
sync_bytes
);
len
=
decode_base64
(
params
[
i
],
b64
);
len
=
g_base64_decode_step
(
params
[
i
],
-
1
,
b64
,
&
state
,
&
save
);
total
+=
len
+
sizeof
(
sync_bytes
);
b64
+=
len
;
}
...
...
@@ -335,12 +290,16 @@ gst_rtp_h264_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
/* start with 7 bytes header */
len
=
7
;
for
(
i
=
0
;
params
[
i
];
i
++
)
{
g
int
nal_len
;
g
size
nal_len
;
guint8
*
nalp
;
guint
save
=
0
;
gint
state
=
0
;
nal_len
=
strlen
(
params
[
i
]);
nalp
=
g_malloc
(
nal_len
+
2
);
nal_len
=
decode_base64
(
params
[
i
],
nalp
+
2
);
nal_len
=
g_base64_decode_step
(
params
[
i
],
nal_len
,
nalp
+
2
,
&
state
,
&
save
);
nalp
[
0
]
=
(
nal_len
>>
8
)
&
0xff
;
nalp
[
1
]
=
nal_len
&
0xff
;
len
+=
nal_len
+
2
;
...
...
gst/rtp/gstrtph264pay.c
View file @
77e26375
...
...
@@ -206,31 +206,6 @@ gst_rtp_h264_pay_finalize (GObject * object)
G_OBJECT_CLASS
(
parent_class
)
->
finalize
(
object
);
}
static
gchar
*
encode_base64
(
const
guint8
*
in
,
guint
size
,
guint
*
len
)
{
gchar
*
ret
,
*
d
;
static
const
gchar
*
v
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
*
len
=
((
size
+
2
)
/
3
)
*
4
;
d
=
ret
=
(
gchar
*
)
g_malloc
(
*
len
+
1
);
for
(;
size
;
in
+=
3
)
{
/* process tuplets */
*
d
++
=
v
[
in
[
0
]
>>
2
];
/* byte 1: high 6 bits (1) */
/* byte 2: low 2 bits (1), high 4 bits (2) */
*
d
++
=
v
[((
in
[
0
]
<<
4
)
+
(
--
size
?
(
in
[
1
]
>>
4
)
:
0
))
&
0x3f
];
/* byte 3: low 4 bits (2), high 2 bits (3) */
*
d
++
=
size
?
v
[((
in
[
1
]
<<
2
)
+
(
--
size
?
(
in
[
2
]
>>
6
)
:
0
))
&
0x3f
]
:
'='
;
/* byte 4: low 6 bits (3) */
*
d
++
=
size
?
v
[
in
[
2
]
&
0x3f
]
:
'='
;
if
(
size
)
size
--
;
/* count third character if processed */
}
*
d
=
'\0'
;
/* tie off string */
return
ret
;
/* return the resulting string */
}
static
gboolean
gst_rtp_h264_pay_setcaps
(
GstBaseRTPPayload
*
basepayload
,
GstCaps
*
caps
)
{
...
...
@@ -295,7 +270,6 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
for
(
i
=
0
;
i
<
num_sps
;
i
++
)
{
gchar
*
set
;
guint
len
;
if
(
size
<
2
)
goto
avcc_error
;
...
...
@@ -309,7 +283,7 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
if
(
size
<
nal_size
)
goto
avcc_error
;
set
=
encode_base64
(
data
,
nal_size
,
&
len
);
set
=
g_base64_encode
(
data
,
nal_size
);
g_string_append_printf
(
sprops
,
"%s%s"
,
count
?
","
:
""
,
set
);
count
++
;
g_free
(
set
);
...
...
@@ -328,7 +302,6 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
GST_DEBUG_OBJECT
(
rtph264pay
,
"num PPS %u"
,
num_pps
);
for
(
i
=
0
;
i
<
num_pps
;
i
++
)
{
gchar
*
set
;
guint
len
;
if
(
size
<
2
)
goto
avcc_error
;
...
...
@@ -342,7 +315,7 @@ gst_rtp_h264_pay_setcaps (GstBaseRTPPayload * basepayload, GstCaps * caps)
if
(
size
<
nal_size
)
goto
avcc_error
;
set
=
encode_base64
(
data
,
nal_size
,
&
len
);
set
=
g_base64_encode
(
data
,
nal_size
);
g_string_append_printf
(
sprops
,
"%s%s"
,
count
?
","
:
""
,
set
);
count
++
;
g_free
(
set
);
...
...
@@ -553,16 +526,15 @@ gst_rtp_h264_pay_parse_sps_pps (GstBaseRTPPayload * basepayload,
gchar
*
sps
;
gchar
*
pps
;
gchar
*
sprops
;
guint
len
;
/* profile is 24 bit. Force it to respect the limit */
profile
=
g_strdup_printf
(
"%06x"
,
payloader
->
profile
&
0xffffff
);
/* build the sprop-parameter-sets */
sps
=
(
payloader
->
sps_len
>
0
)
?
encode_base64
(
payloader
->
sps
,
payloader
->
sps_len
,
&
len
)
:
NULL
;
?
g_base64_encode
(
payloader
->
sps
,
payloader
->
sps_
len
)
:
NULL
;
pps
=
(
payloader
->
pps_len
>
0
)
?
encode_base64
(
payloader
->
pps
,
payloader
->
pps_len
,
&
len
)
:
NULL
;
?
g_base64_encode
(
payloader
->
pps
,
payloader
->
pps_
len
)
:
NULL
;
if
(
sps
)
sprops
=
g_strjoin
(
","
,
sps
,
pps
,
NULL
);
...
...
gst/rtp/gstrtptheoradepay.c
View file @
77e26375
...
...
@@ -124,6 +124,7 @@ gst_rtp_theora_depay_init (GstRtpTheoraDepay * rtptheoradepay,
{
rtptheoradepay
->
adapter
=
gst_adapter_new
();
}
static
void
gst_rtp_theora_depay_finalize
(
GObject
*
object
)
{
...
...
@@ -134,54 +135,6 @@ gst_rtp_theora_depay_finalize (GObject * object)
G_OBJECT_CLASS
(
parent_class
)
->
finalize
(
object
);
}
static
const
guint8
a2bin
[
256
]
=
{
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
62
,
64
,
64
,
64
,
63
,
52
,
53
,
54
,
55
,
56
,
57
,
58
,
59
,
60
,
61
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
64
,
64
,
64
,
64
,
64
,
64
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
,
51
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
,
64
};
static
guint
decode_base64
(
const
gchar
*
in
,
guint8
*
out
)
{
guint8
v1
,
v2
;
guint
len
=
0
;
v1
=
a2bin
[(
gint
)
*
in
];
while
(
v1
<=
63
)
{
/* read 4 bytes, write 3 bytes, invalid base64 are zeroes */
v2
=
a2bin
[(
gint
)
*
++
in
];
*
out
++
=
(
v1
<<
2
)
|
((
v2
&
0x3f
)
>>
4
);
v1
=
(
v2
>
63
?
64
:
a2bin
[(
gint
)
*
++
in
]);
*
out
++
=
(
v2
<<
4
)
|
((
v1
&
0x3f
)
>>
2
);
v2
=
(
v1
>
63
?
64
:
a2bin
[(
gint
)
*
++
in
]);
*
out
++
=
(
v1
<<
6
)
|
(
v2
&
0x3f
);
v1
=
(
v2
>
63
?
64
:
a2bin
[(
gint
)
*
++
in
]);
len
+=
3
;
}
/* move to '\0' */
while
(
*
in
!=
'\0'
)
in
++
;
/* subtract padding */
while
(
len
>
0
&&
*--
in
==
'='
)
len
--
;
return
len
;
}
static
gboolean
gst_rtp_theora_depay_parse_configuration
(
GstRtpTheoraDepay
*
rtptheoradepay
,
const
gchar
*
configuration
)
...
...
@@ -189,15 +142,14 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
GstBuffer
*
buf
;
guint32
num_headers
;
guint8
*
data
;
g
uint
size
;
g
size
size
;
gint
i
,
j
;
/* deserialize base64 to buffer */
size
=
strlen
(
configuration
);
GST_DEBUG_OBJECT
(
rtptheoradepay
,
"base64 config size %u"
,
size
);
data
=
g_malloc
(
size
);
size
=
decode_base64
(
configuration
,
data
);
data
=
g_base64_decode
(
configuration
,
&
size
);
GST_DEBUG_OBJECT
(
rtptheoradepay
,
"config size %u"
,
size
);
...
...
gst/rtp/gstrtptheorapay.c
View file @
77e26375
...
...
@@ -233,31 +233,6 @@ gst_rtp_theora_pay_flush_packet (GstRtpTheoraPay * rtptheorapay)
return
ret
;
}
static
gchar
*
encode_base64
(
const
guint8
*
in
,
guint
size
,
guint
*
len
)
{
gchar
*
ret
,
*
d
;
static
const
gchar
*
v
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
*
len
=
((
size
+
2
)
/
3
)
*
4
;
d
=
ret
=
(
gchar
*
)
g_malloc
(
*
len
+
1
);
for
(;
size
;
in
+=
3
)
{
/* process tuplets */
*
d
++
=
v
[
in
[
0
]
>>
2
];
/* byte 1: high 6 bits (1) */
/* byte 2: low 2 bits (1), high 4 bits (2) */
*
d
++
=
v
[((
in
[
0
]
<<
4
)
+
(
--
size
?
(
in
[
1
]
>>
4
)
:
0
))
&
0x3f
];
/* byte 3: low 4 bits (2), high 2 bits (3) */
*
d
++
=
size
?
v
[((
in
[
1
]
<<
2
)
+
(
--
size
?
(
in
[
2
]
>>
6
)
:
0
))
&
0x3f
]
:
'='
;
/* byte 4: low 6 bits (3) */
*
d
++
=
size
?
v
[
in
[
2
]
&
0x3f
]
:
'='
;
if
(
size
)
size
--
;
/* count third character if processed */
}
*
d
=
'\0'
;
/* tie off string */
return
ret
;
/* return the resulting string */
}
static
gboolean
gst_rtp_theora_pay_finish_headers
(
GstBaseRTPPayload
*
basepayload
)
{
...
...
@@ -412,7 +387,7 @@ gst_rtp_theora_pay_finish_headers (GstBaseRTPPayload * basepayload)
}
/* serialize to base64 */
configuration
=
encode_base64
(
config
,
configlen
,
&
size
);
configuration
=
g_base64_encode
(
config
,
configlen
);
g_free
(
config
);
/* configure payloader settings */
...
...
gst/rtp/gstrtpvorbispay.c
View file @
77e26375
...
...
@@ -222,32 +222,6 @@ gst_rtp_vorbis_pay_flush_packet (GstRtpVorbisPay * rtpvorbispay)
return
ret
;
}
static
gchar
*
encode_base64
(
const
guint8
*
in
,
guint
size
,
guint
*
len
)
{
gchar
*
ret
,
*
d
;
static
const
gchar
v
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
*
len
=
((
size
+
2
)
/
3
)
*
4
;
d
=
ret
=
(
gchar
*
)
g_malloc
(
*
len
+
1
);
for
(;
size
;
in
+=
3
)
{
/* process tuplets */
*
d
++
=
v
[
in
[
0
]
>>
2
];
/* byte 1: high 6 bits (1) */
/* byte 2: low 2 bits (1), high 4 bits (2) */
*
d
++
=
v
[((
in
[
0
]
<<
4
)
+
(
--
size
?
(
in
[
1
]
>>
4
)
:
0
))
&
0x3f
];
/* byte 3: low 4 bits (2), high 2 bits (3) */
*
d
++
=
size
?
v
[((
in
[
1
]
<<
2
)
+
(
--
size
?
(
in
[
2
]
>>
6
)
:
0
))
&
0x3f
]
:
'='
;
/* byte 4: low 6 bits (3) */
*
d
++
=
size
?
v
[
in
[
2
]
&
0x3f
]
:
'='
;
if
(
size
)
size
--
;
/* count third character if processed */
}
*
d
=
'\0'
;
/* tie off string */
return
ret
;
/* return the resulting string */
}
static
gboolean
gst_rtp_vorbis_pay_finish_headers
(
GstBaseRTPPayload
*
basepayload
)
{
...
...
@@ -398,7 +372,7 @@ gst_rtp_vorbis_pay_finish_headers (GstBaseRTPPayload * basepayload)
}
/* serialize to base64 */
configuration
=
encode_base64
(
config
,
configlen
,
&
size
);
configuration
=
g_base64_encode
(
config
,
configlen
);
g_free
(
config
);
/* configure payloader settings */
...
...
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