Updated function signatures of DTSC header calls to be more compatible.
This commit is contained in:
parent
033ec8d692
commit
5a2ee56e6b
2 changed files with 57 additions and 47 deletions
32
lib/dtsc.h
32
lib/dtsc.h
|
@ -206,16 +206,16 @@ namespace DTSC {
|
||||||
/// When deleting this object, make sure to remove all DTSC::Part associated with it, if any. If you fail doing this, it *will* cause data corruption.
|
/// When deleting this object, make sure to remove all DTSC::Part associated with it, if any. If you fail doing this, it *will* cause data corruption.
|
||||||
class Key {
|
class Key {
|
||||||
public:
|
public:
|
||||||
long long unsigned int getBpos();
|
unsigned long long getBpos();
|
||||||
void setBpos(long long unsigned int newBpos);
|
void setBpos(unsigned long long newBpos);
|
||||||
long getLength();
|
unsigned long getLength();
|
||||||
void setLength(long newLength);
|
void setLength(unsigned long newLength);
|
||||||
unsigned short getNumber();
|
unsigned long getNumber();
|
||||||
void setNumber(unsigned short newNumber);
|
void setNumber(unsigned long newNumber);
|
||||||
short getParts();
|
unsigned short getParts();
|
||||||
void setParts(short newParts);
|
void setParts(unsigned short newParts);
|
||||||
long getTime();
|
unsigned long long getTime();
|
||||||
void setTime(long newTime);
|
void setTime(unsigned long long newTime);
|
||||||
char * getData();
|
char * getData();
|
||||||
void toPrettyString(std::ostream & str, int indent = 0);
|
void toPrettyString(std::ostream & str, int indent = 0);
|
||||||
private:
|
private:
|
||||||
|
@ -232,14 +232,14 @@ namespace DTSC {
|
||||||
///\brief Basic class for storage of data associated with fragments.
|
///\brief Basic class for storage of data associated with fragments.
|
||||||
class Fragment {
|
class Fragment {
|
||||||
public:
|
public:
|
||||||
long getDuration();
|
unsigned long getDuration();
|
||||||
void setDuration(long newDuration);
|
void setDuration(unsigned long newDuration);
|
||||||
char getLength();
|
char getLength();
|
||||||
void setLength(char newLength);
|
void setLength(char newLength);
|
||||||
short getNumber();
|
unsigned long getNumber();
|
||||||
void setNumber(short newNumber);
|
void setNumber(unsigned long newNumber);
|
||||||
long getSize();
|
unsigned long getSize();
|
||||||
void setSize(long newSize);
|
void setSize(unsigned long newSize);
|
||||||
char * getData();
|
char * getData();
|
||||||
void toPrettyString(std::ostream & str, int indent = 0);
|
void toPrettyString(std::ostream & str, int indent = 0);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -7,29 +7,46 @@
|
||||||
#define AUDIO_KEY_INTERVAL 5000 ///< This define controls the keyframe interval for non-video tracks, such as audio and metadata tracks.
|
#define AUDIO_KEY_INTERVAL 5000 ///< This define controls the keyframe interval for non-video tracks, such as audio and metadata tracks.
|
||||||
|
|
||||||
/// Retrieves a short in network order from the pointer p.
|
/// Retrieves a short in network order from the pointer p.
|
||||||
static short btohs(char * p) {
|
static unsigned short btohs(char * p) {
|
||||||
return (p[0] << 8) + p[1];
|
return ((unsigned short)p[0] << 8) | p[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores a short value of val in network order to the pointer p.
|
/// Stores a short value of val in network order to the pointer p.
|
||||||
static void htobs(char * p, short val) {
|
static void htobs(char * p, unsigned short val) {
|
||||||
p[0] = (val >> 8) & 0xFF;
|
p[0] = (val >> 8) & 0xFF;
|
||||||
p[1] = val & 0xFF;
|
p[1] = val & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves a long in network order from the pointer p.
|
/// Retrieves a long in network order from the pointer p.
|
||||||
static long btohl(char * p) {
|
static unsigned long btohl(char * p) {
|
||||||
return (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
|
return ((unsigned long)p[0] << 24) | ((unsigned long)p[1] << 16) | ((unsigned long)p[2] << 8) | p[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores a long value of val in network order to the pointer p.
|
/// Stores a long value of val in network order to the pointer p.
|
||||||
static void htobl(char * p, long val) {
|
static void htobl(char * p, unsigned long val) {
|
||||||
p[0] = (val >> 24) & 0xFF;
|
p[0] = (val >> 24) & 0xFF;
|
||||||
p[1] = (val >> 16) & 0xFF;
|
p[1] = (val >> 16) & 0xFF;
|
||||||
p[2] = (val >> 8) & 0xFF;
|
p[2] = (val >> 8) & 0xFF;
|
||||||
p[3] = val & 0xFF;
|
p[3] = val & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves a long long in network order from the pointer p.
|
||||||
|
static unsigned long long btohll(char * p) {
|
||||||
|
return ((unsigned long long)p[0] << 56) | ((unsigned long long)p[1] << 48) | ((unsigned long long)p[2] << 40) | ((unsigned long long)p[3] << 32) | ((unsigned long)p[4] << 24) | ((unsigned long)p[5] << 16) | ((unsigned long)p[6] << 8) | p[7];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stores a long value of val in network order to the pointer p.
|
||||||
|
static void htobll(char * p, unsigned long long val) {
|
||||||
|
p[0] = (val >> 56) & 0xFF;
|
||||||
|
p[1] = (val >> 48) & 0xFF;
|
||||||
|
p[2] = (val >> 40) & 0xFF;
|
||||||
|
p[3] = (val >> 32) & 0xFF;
|
||||||
|
p[4] = (val >> 24) & 0xFF;
|
||||||
|
p[5] = (val >> 16) & 0xFF;
|
||||||
|
p[6] = (val >> 8) & 0xFF;
|
||||||
|
p[7] = val & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
namespace DTSC {
|
namespace DTSC {
|
||||||
/// Default constructor for packets - sets a null pointer and invalid packet.
|
/// Default constructor for packets - sets a null pointer and invalid packet.
|
||||||
Packet::Packet() {
|
Packet::Packet() {
|
||||||
|
@ -860,58 +877,51 @@ namespace DTSC {
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the byteposition of a keyframe
|
///\brief Returns the byteposition of a keyframe
|
||||||
long long unsigned int Key::getBpos() {
|
unsigned long long Key::getBpos() {
|
||||||
return (((long long unsigned int)data[0] << 32) | (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4]);
|
return btohll(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the byteposition of a keyframe
|
void Key::setBpos(unsigned long long newBpos) {
|
||||||
void Key::setBpos(long long unsigned int newBpos) {
|
htobll(data, newBpos);
|
||||||
data[4] = newBpos & 0xFF;
|
|
||||||
data[3] = (newBpos >> 8) & 0xFF;
|
|
||||||
data[2] = (newBpos >> 16) & 0xFF;
|
|
||||||
data[1] = (newBpos >> 24) & 0xFF;
|
|
||||||
data[0] = (newBpos >> 32) & 0xFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the byteposition of a keyframe
|
unsigned long Key::getLength() {
|
||||||
long Key::getLength() {
|
|
||||||
return ((data[5] << 16) | (data[6] << 8) | data[7]);
|
return ((data[5] << 16) | (data[6] << 8) | data[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the byteposition of a keyframe
|
void Key::setLength(unsigned long newLength) {
|
||||||
void Key::setLength(long newLength) {
|
|
||||||
data[7] = newLength & 0xFF;
|
data[7] = newLength & 0xFF;
|
||||||
data[6] = (newLength >> 8) & 0xFF;
|
data[6] = (newLength >> 8) & 0xFF;
|
||||||
data[5] = (newLength >> 16) & 0xFF;
|
data[5] = (newLength >> 16) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the number of a keyframe
|
///\brief Returns the number of a keyframe
|
||||||
unsigned short Key::getNumber() {
|
unsigned long Key::getNumber() {
|
||||||
return btohs(data + 8);
|
return btohs(data + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the number of a keyframe
|
///\brief Sets the number of a keyframe
|
||||||
void Key::setNumber(unsigned short newNumber) {
|
void Key::setNumber(unsigned long newNumber) {
|
||||||
htobs(data + 8, newNumber);
|
htobs(data + 8, newNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the number of parts of a keyframe
|
///\brief Returns the number of parts of a keyframe
|
||||||
short Key::getParts() {
|
unsigned short Key::getParts() {
|
||||||
return btohs(data + 10);
|
return btohs(data + 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the number of parts of a keyframe
|
///\brief Sets the number of parts of a keyframe
|
||||||
void Key::setParts(short newParts) {
|
void Key::setParts(unsigned short newParts) {
|
||||||
htobs(data + 10, newParts);
|
htobs(data + 10, newParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the timestamp of a keyframe
|
///\brief Returns the timestamp of a keyframe
|
||||||
long Key::getTime() {
|
unsigned long long Key::getTime() {
|
||||||
return btohl(data + 12);
|
return btohl(data + 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the timestamp of a keyframe
|
///\brief Sets the timestamp of a keyframe
|
||||||
void Key::setTime(long newTime) {
|
void Key::setTime(unsigned long long newTime) {
|
||||||
htobl(data + 12, newTime);
|
htobl(data + 12, newTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,12 +938,12 @@ namespace DTSC {
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the duration of this fragment
|
///\brief Returns the duration of this fragment
|
||||||
long Fragment::getDuration() {
|
unsigned long Fragment::getDuration() {
|
||||||
return btohl(data);
|
return btohl(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the duration of this fragment
|
///\brief Sets the duration of this fragment
|
||||||
void Fragment::setDuration(long newDuration) {
|
void Fragment::setDuration(unsigned long newDuration) {
|
||||||
htobl(data, newDuration);
|
htobl(data, newDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,22 +958,22 @@ namespace DTSC {
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the number of the first keyframe in this fragment
|
///\brief Returns the number of the first keyframe in this fragment
|
||||||
short Fragment::getNumber() {
|
unsigned long Fragment::getNumber() {
|
||||||
return btohs(data + 5);
|
return btohs(data + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the number of the first keyframe in this fragment
|
///\brief Sets the number of the first keyframe in this fragment
|
||||||
void Fragment::setNumber(short newNumber) {
|
void Fragment::setNumber(unsigned long newNumber) {
|
||||||
htobs(data + 5, newNumber);
|
htobs(data + 5, newNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Returns the size of a fragment
|
///\brief Returns the size of a fragment
|
||||||
long Fragment::getSize() {
|
unsigned long Fragment::getSize() {
|
||||||
return btohl(data + 7);
|
return btohl(data + 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
///\brief Sets the size of a fragement
|
///\brief Sets the size of a fragement
|
||||||
void Fragment::setSize(long newSize) {
|
void Fragment::setSize(unsigned long newSize) {
|
||||||
htobl(data + 7, newSize);
|
htobl(data + 7, newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue