Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Opus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Opus
Commits
265b40c2
Commit
265b40c2
authored
14 years ago
by
Jean-Marc Valin
Browse files
Options
Downloads
Patches
Plain Diff
Initial code for parsing/packing/unpacking packets
Warning: untested, may not even compile
parent
57de8a36
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/framepack.c
+108
-0
108 additions, 0 deletions
src/framepack.c
with
108 additions
and
0 deletions
src/framepack.c
0 → 100644
+
108
−
0
View file @
265b40c2
/* Copyright (c) 2010 Xiph.Org Foundation, Skype Limited
Written by Jean-Marc Valin and Koen Vos */
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of the Xiph.org Foundation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
static
int
decode_length
(
unsigned
char
*
c
,
int
len
)
{
int
tmp
;
tmp
=
c
[
0
];
if
(
len
<
1
)
return
-
1
;
if
(
tmp
>=
252
)
{
if
(
len
>=
2
)
return
4
*
c
[
1
]
+
(
tmp
&
0x3
)
+
252
;
else
return
-
1
;
}
else
{
return
tmp
;
}
}
int
count_frames
(
unsigned
char
*
packet
,
int
len
)
{
int
sz
=
packet
[
0
]
&
0x7
;
if
(
sz
==
0
)
return
1
;
else
if
(
sz
==
1
||
sz
==
4
)
return
2
;
else
if
(
sz
==
2
||
sz
==
5
)
return
3
;
else
if
(
sz
==
3
)
{
/* Many packets, same size */
int
count
,
payload
;
int
flen
=
decode_length
(
packet
+
1
,
len
-
1
);
if
(
flen
<=
0
)
return
-
1
;
payload
=
len
-
2
;
if
(
flen
>=
252
)
payload
--
;
count
=
payload
/
flen
;
if
(
count
*
flen
==
payload
)
return
count
;
else
return
-
1
;
}
else
if
(
sz
==
6
)
{
/* Many packets, different sizes */
int
count
=
0
;
int
pos
=
1
;
int
bytes
=
1
;
while
(
bytes
<
len
)
{
int
tmp
=
1
;
int
flen
=
decode_length
(
packet
+
pos
,
len
-
bytes
);
if
(
flen
==-
1
)
return
-
1
;
if
(
flen
>=
252
)
tmp
=
2
;
pos
+=
tmp
;
bytes
+=
tmp
+
flen
;
count
++
;
}
if
(
bytes
!=
len
)
return
-
1
;
else
return
count
;
}
else
{
}
}
#define MAX_FRAMES 256
int
hybrid_merge_packets
(
unsigned
char
**
packets
,
int
*
len
,
unsigned
*
output
,
int
maxlen
)
{
unsigned
char
cfg
[
MAX_FRAMES
];
unsigned
char
len
[
MAX_FRAMES
];
int
nb_frames
=
0
;
}
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