// although only at a keyframe.
// -2 means we want to send from the _beginning_ of the backlog.
// -3 means we sent the header only.
- static const size_t STREAM_POS_AT_END = -1;
- static const size_t STREAM_POS_AT_START = -2;
- static const size_t STREAM_POS_HEADER_ONLY = -3;
+ static const uint64_t STREAM_POS_AT_END = -1;
+ static const uint64_t STREAM_POS_AT_START = -2;
+ static const uint64_t STREAM_POS_HEADER_ONLY = -3;
// Once we go into WAITING_FOR_KEYFRAME, PREBUFFERING or SENDING_DATA,
// these negative values will be translated to real numbers.
- size_t stream_pos = 0;
+ uint64_t stream_pos = 0;
// Position at which to end the stream (one-past-the-end, used for fragments).
// -1 means never to end; this is the common case.
- static const size_t STREAM_POS_NO_END = -1;
- size_t stream_pos_end = 0;
+ static const uint64_t STREAM_POS_NO_END = -1;
+ uint64_t stream_pos_end = 0;
// Number of bytes we've sent of data. Only relevant for SENDING_DATA.
- size_t bytes_sent = 0;
+ uint64_t bytes_sent = 0;
// Number of times we've skipped forward due to the backlog being too big,
// and how many bytes we've skipped over in all. Only relevant for SENDING_DATA.
- size_t bytes_lost = 0, num_loss_events = 0;
+ uint64_t bytes_lost = 0, num_loss_events = 0;
TLSContext *tls_context = nullptr;
const unsigned char *tls_data_to_send = nullptr;
#include <assert.h>
#include <errno.h>
+#include <inttypes.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <pthread.h>
response.append(buf);
} else if (client->stream_pos_end != Client::STREAM_POS_NO_END) {
char buf[64];
- snprintf(buf, sizeof(buf), "Content-length: %zu\r\n", client->stream_pos_end - client->stream_pos);
+ snprintf(buf, sizeof(buf), "Content-length: %" PRIu64 "\r\n", client->stream_pos_end - client->stream_pos);
response.append(buf);
}
if (client->http_11) {
#include <assert.h>
#include <errno.h>
+#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <netinet/in.h>
Stream::Stream(const string &url,
size_t backlog_size,
- size_t prebuffering_bytes,
+ uint64_t prebuffering_bytes,
Encoding encoding,
Encoding src_encoding,
unsigned hls_frag_duration,
"#EXTM3U\r\n"
"#EXT-X-VERSION:7\r\n"
"#EXT-X-TARGETDURATION:%u\r\n"
- "#EXT-X-MEDIA-SEQUENCE:%zu\r\n"
- "#EXT-X-DISCONTINUITY-SEQUENCE:%zu\r\n",
+ "#EXT-X-MEDIA-SEQUENCE:%" PRIu64 "\r\n"
+ "#EXT-X-DISCONTINUITY-SEQUENCE:%" PRIu64 "\r\n",
hls_frag_duration,
first_fragment_index,
discontinuity_counter);
if (fragments.size() >= 3) {
for (size_t i = 0; i < fragments.size() - 2; ++i) {
char buf[256];
- snprintf(buf, sizeof(buf), "#EXTINF:%f,\r\n%s?frag=%zu-%zu\r\n",
+ snprintf(buf, sizeof(buf), "#EXTINF:%f,\r\n%s?frag=%" PRIu64 "-%" PRIu64 "\r\n",
fragments[i + 1].pts - fragments[i].pts,
url.c_str(),
fragments[i].byte_position,
Stream(const std::string &url,
size_t backlog_size,
- size_t prebuffering_bytes,
+ uint64_t prebuffering_bytes,
Encoding encoding,
Encoding src_encoding,
unsigned hls_frag_duration,
// This is basically to force a buffer on the client, which can help
// if the client expects us to be able to fill up the buffer much
// faster than realtime (ie., it expects a static file).
- size_t prebuffering_bytes;
+ uint64_t prebuffering_bytes;
// How many bytes this stream have received. Can very well be larger
// than <backlog_size>, since the buffer wraps.
- size_t bytes_received = 0;
+ uint64_t bytes_received = 0;
// A list of points in the stream that is suitable to start new clients at
// (after having sent the header). Empty if no such point exists yet.
- std::deque<size_t> suitable_starting_points;
+ std::deque<uint64_t> suitable_starting_points;
// A list of HLS fragment boundaries currently in the backlog; the first fragment
// is between point 0 and 1, the second is between 1 and 2, and so on.
// extended and thus should not be output. So the last fragment output is
// from points N-3..N-2.
struct FragmentStart {
- size_t byte_position;
+ uint64_t byte_position;
double pts;
};
std::deque<FragmentStart> fragments;