Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.protos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.protos
Commits
6176e8bb
Commit
6176e8bb
authored
May 11, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add flags to Proto
parent
da823fa5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
4 deletions
+30
-4
mm.c
src/MovMem/mm.c
+4
-1
mm.h
src/MovMem/mm.h
+0
-2
proto.c
src/proto.c
+8
-0
proto.h
src/proto.h
+11
-1
protoTestCases.c
tests/protoTestCases.c
+7
-0
No files found.
src/MovMem/mm.c
View file @
6176e8bb
...
...
@@ -12,6 +12,8 @@ static int mmRead(void *priv, uint8_t *buf, int size) {
MemMovContext
*
context
=
mmc
(
proto
);
List
*
buffers
=
mmpBuffer
(
proto
);
int
flag
=
protoFlag
(
&
proto
->
Base
);
if
((
priv
==
NULL
||
buf
==
NULL
||
size
<
0
))
{
return
AVERROR
(
EINVAL
);
}
...
...
@@ -28,7 +30,8 @@ static int mmRead(void *priv, uint8_t *buf, int size) {
free
(
info
);
}
if
(
mmcIsEOF
(
context
))
{
if
(
mmcIsEOF
(
context
)
||
flag
&
PROTO_FLAG_EOF
)
{
protoSetFlag
(
&
proto
->
Base
,
PROTO_FLAG_EOF
);
return
AVERROR_EOF
;
}
...
...
src/MovMem/mm.h
View file @
6176e8bb
...
...
@@ -49,6 +49,4 @@ void mmcReset(MemMovContext *mm);
void
destroyBufferInfo
(
BufferInfo
**
);
#endif
/* MM_H */
src/proto.c
View file @
6176e8bb
...
...
@@ -8,6 +8,7 @@ Proto* createProto(ReadFunc rf, WriteFunc wf, SeekFunc sf, void *priv) {
p
->
seek
=
sf
;
p
->
priv
=
priv
;
p
->
ctx
=
NULL
;
p
->
flag
=
PROTO_NO_FLAG_SET
;
return
p
;
}
...
...
@@ -56,3 +57,10 @@ AVIOContext* proto2AVIO(Proto *p, size_t bufSize) {
return
ioctx
;
}
void
protoUnsetFlag
(
Proto
*
p
,
PROTO_FLAG
flag_
)
{
int
flag
=
protoFlag
(
p
);
flag_
=
flag_
^
PROTO_ALL_FLAG_SET
;
p
->
flag
=
flag
&
flag_
;
}
src/proto.h
View file @
6176e8bb
...
...
@@ -7,15 +7,21 @@
typedef
int
(
*
ReadFunc
)(
void
*
priv
,
uint8_t
*
buf
,
int
size
);
typedef
int
(
*
WriteFunc
)(
void
*
priv
,
uint8_t
*
buf
,
int
size
);
typedef
int64_t
(
*
SeekFunc
)(
void
*
opaque
,
int64_t
offset
,
int
whence
);
typedef
void
(
*
ProtoDestructor
)(
void
**
);
typedef
enum
{
PROTO_NO_FLAG_SET
=
0x0000
,
PROTO_FLAG_EOF
=
0x0001
,
PROTO_ALL_FLAG_SET
=
0x1111
,
}
PROTO_FLAG
;
typedef
struct
Proto
{
int
(
*
read
)(
void
*
priv
,
uint8_t
*
buf
,
int
size
);
int
(
*
write
)(
void
*
priv
,
uint8_t
*
buf
,
int
size
);
int64_t
(
*
seek
)(
void
*
opaque
,
int64_t
offset
,
int
whence
);
void
*
priv
;
AVIOContext
*
ctx
;
uint16_t
flag
;
}
Proto
;
/* Member function implement as macros */
...
...
@@ -26,12 +32,16 @@ typedef struct Proto {
#define write(P, buf, size) ((P)->write((P)->priv, (buf), (size)))
#define seek(P, offset, whence) ((P)->seek((P)->priv, (offset), (whence)))
#define Super(DerivedPtr) ((Proto*)(DerivedPtr))
#define protoFlag(P) ((P)->flag)
#define protoSetFlag(P, F) ((P)->flag = (P)->flag | (F))
/* Prototypes */
Proto
*
createProto
(
ReadFunc
rf
,
WriteFunc
wr
,
SeekFunc
sf
,
void
*
priv
);
void
destroyProto
(
Proto
**
);
Proto
createProto_
(
ReadFunc
rf
,
WriteFunc
wr
,
SeekFunc
sf
,
void
*
priv
);
void
destroyProto_
(
Proto
*
);
void
protoUnsetFlag
(
Proto
*
p
,
PROTO_FLAG
flag
);
AVIOContext
*
proto2AVIO
(
Proto
*
p
,
size_t
bufSize
);
...
...
tests/protoTestCases.c
View file @
6176e8bb
...
...
@@ -107,3 +107,10 @@ CTEST2(PROTO_TEST, TO_AVIO) {
ASSERT_EQUAL
(
ioctx
->
write_packet
,
writeFake
);
ASSERT_EQUAL
(
ioctx
->
seek
,
seekFake
);
}
CTEST2
(
PROTO_TEST
,
FLAGS_SET_UNSET
)
{
ASSERT_EQUAL
(
protoFlag
(
data
->
proto
),
PROTO_NO_FLAG_SET
);
protoSetFlag
(
data
->
proto
,
PROTO_FLAG_EOF
);
ASSERT_EQUAL
(
protoFlag
(
data
->
proto
),
PROTO_FLAG_EOF
);
}
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