-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The decoder initially read from the socket, decoded the video and sent the decoded frames to the screen: +---------+ +----------+ socket ---> | decoder | ---> | screen | +---------+ +----------+ The design was simple, but the decoder had several responsabilities. Then we added the recording feature, so we added a recorder, which reused the packets received from the socket managed by the decoder: +----------+ ---> | screen | +---------+ / +----------+ socket ---> | decoder | ---- +---------+ \ +----------+ ---> | recorder | +----------+ This lack of separation of concerns now have concrete implications: we could not (properly) disable the decoder/display to only record the video. Therefore, split the decoder to extract the stream: +----------+ +----------+ ---> | decoder | ---> | screen | +---------+ / +----------+ +----------+ socket ---> | stream | ---- +---------+ \ +----------+ ---> | recorder | +----------+ This will allow to record the stream without decoding the video.
- Loading branch information
Showing
7 changed files
with
378 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ src = [ | |
'src/server.c', | ||
'src/str_util.c', | ||
'src/tiny_xpm.c', | ||
'src/stream.c', | ||
'src/video_buffer.c', | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,22 @@ | ||
#ifndef DECODER_H | ||
#define DECODER_H | ||
|
||
#include <libavformat/avformat.h> | ||
#include <SDL2/SDL_stdinc.h> | ||
#include <SDL2/SDL_thread.h> | ||
|
||
#include "common.h" | ||
#include "net.h" | ||
|
||
struct video_buffer; | ||
|
||
struct frame_meta { | ||
uint64_t pts; | ||
struct frame_meta *next; | ||
}; | ||
|
||
struct decoder { | ||
struct video_buffer *video_buffer; | ||
socket_t video_socket; | ||
SDL_Thread *thread; | ||
struct recorder *recorder; | ||
struct receiver_state { | ||
// meta (in order) for frames not consumed yet | ||
struct frame_meta *frame_meta_queue; | ||
size_t remaining; // remaining bytes to receive for the current frame | ||
} receiver_state; | ||
AVCodecContext *codec_ctx; | ||
}; | ||
|
||
void decoder_init(struct decoder *decoder, struct video_buffer *vb, | ||
socket_t video_socket, struct recorder *recoder); | ||
SDL_bool decoder_start(struct decoder *decoder); | ||
void decoder_stop(struct decoder *decoder); | ||
void decoder_join(struct decoder *decoder); | ||
void decoder_init(struct decoder *decoder, struct video_buffer *vb); | ||
|
||
SDL_bool decoder_open(struct decoder *decoder, AVCodec *codec); | ||
void decoder_close(struct decoder *decoder); | ||
|
||
SDL_bool decoder_push(struct decoder *decoder, AVPacket *packet); | ||
void decoder_interrupt(struct decoder *decoder); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#define EVENT_NEW_SESSION SDL_USEREVENT | ||
#define EVENT_NEW_FRAME (SDL_USEREVENT + 1) | ||
#define EVENT_DECODER_STOPPED (SDL_USEREVENT + 2) | ||
#define EVENT_STREAM_STOPPED (SDL_USEREVENT + 2) |
Oops, something went wrong.