GUAC-236: Record internal presentation timestamp in same format as libavcodec.

This commit is contained in:
Michael Jumper 2016-03-11 13:27:36 -08:00
parent 9eddaeee3d
commit 38c431e8a2
2 changed files with 13 additions and 13 deletions

View File

@ -102,7 +102,7 @@ guacenc_video* guacenc_video_alloc(const char* path, const char* codec_name,
/* No frames have been written or prepared yet */
video->last_timestamp = 0;
video->current_time = 0;
video->next_pts = 0;
video->next_frame = NULL;
return video;
@ -146,12 +146,11 @@ static int guacenc_video_flush_frame(guacenc_video* video) {
packet.data = NULL;
packet.size = 0;
/* STUB: Write frame to video */
guacenc_log(GUAC_LOG_DEBUG, "Writing frame @ %" PRId64 "ms",
video->current_time);
/* TODO: Write frame to video */
guacenc_log(GUAC_LOG_DEBUG, "Encoding frame #%08" PRId64, video->next_pts);
/* Update internal timestamp */
video->current_time += video->frame_duration;
/* Update presentation timestamp for next frame */
video->next_pts++;
return 0;

View File

@ -29,6 +29,8 @@
#include <guacamole/timestamp.h>
#include <libavcodec/avcodec.h>
#include <stdint.h>
/**
* A video which is actively being encoded. Frames can be added to the video
* as they are generated, along with their associated timestamps, and the
@ -75,19 +77,18 @@ typedef struct guacenc_video {
*/
guacenc_buffer* next_frame;
/**
* The presentation timestamp that should be used for the next frame. This
* is equivalent to the frame number.
*/
int64_t next_pts;
/**
* The timestamp associated with the last frame, or 0 if no frames have yet
* been added.
*/
guac_timestamp last_timestamp;
/**
* The relative position within the current video timeline, where 0 is the
* first frame of video, in milliseconds. This value will be incremented as
* frames are output.
*/
guac_timestamp current_time;
} guacenc_video;
/**