Fixes for HTTP DASH live streaming

This commit is contained in:
Erik Zandvliet 2015-06-29 10:43:31 +02:00 committed by Thulinma
parent e1313e3bb5
commit 06cfc1eed2
4 changed files with 83 additions and 38 deletions

View file

@ -4,6 +4,8 @@
#include "timing.h"
#include <sys/time.h>//for gettimeofday
#include <time.h>//for time and nanosleep
#include <cstring>
#include <cstdio>
//emulate clock_gettime() for OSX compatibility
#if defined(__APPLE__) || defined(__MACH__)
@ -97,3 +99,16 @@ long long unsigned int Util::getMicros(long long unsigned int previous) {
long long int Util::epoch() {
return time(0);
}
std::string Util::getUTCString(){
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
char result[20];
snprintf(result, 20, "%0.4d-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d", ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
return std::string(result);
}

View file

@ -1,5 +1,6 @@
/// \file timing.h
/// Utilities for handling time and timestamps.
#include <string>
#pragma once
@ -12,4 +13,5 @@ namespace Util {
long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds.
long long int getNTP();
long long int epoch(); ///< Gets the amount of seconds since 01/01/1970.
std::string getUTCString();
}