Skip to content

Commit 16bb689

Browse files
committed
Removed appleCompat mode from TS/HLS outputs, now sends identical segments to all client devices
1 parent 90c9d16 commit 16bb689

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/output/output_hls.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ namespace Mist {
184184
}
185185

186186

187-
appleCompat = (H.GetHeader("User-Agent").find("iPad") != std::string::npos) || (H.GetHeader("User-Agent").find("iPod") != std::string::npos)|| (H.GetHeader("User-Agent").find("iPhone") != std::string::npos);
188187
bool VLCworkaround = false;
189188
if (H.GetHeader("User-Agent").substr(0, 3) == "VLC"){
190189
std::string vlcver = H.GetHeader("User-Agent").substr(4);

src/output/output_ts_base.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Mist {
77
ts_from = 0;
88
setBlocking(true);
99
sendRepeatingHeaders = 0;
10-
appleCompat=false;
1110
lastHeaderTime = 0;
1211
}
1312

@@ -70,13 +69,6 @@ namespace Mist {
7069
size_t tmpDataLen = 0;
7170
thisPacket.getString("data", dataPointer, tmpDataLen); //data
7271
uint64_t dataLen = tmpDataLen;
73-
//apple compatibility timestamp correction
74-
if (appleCompat){
75-
packTime -= ts_from;
76-
if (Trk.type == "audio"){
77-
packTime = 0;
78-
}
79-
}
8072
packTime *= 90;
8173
std::string bs;
8274
//prepare bufferstring
@@ -179,6 +171,15 @@ namespace Mist {
179171
long unsigned int tempLen = dataLen;
180172
if (Trk.codec == "AAC"){
181173
tempLen += 7;
174+
//Make sure TS timestamp is sample-aligned, if possible
175+
uint32_t freq = Trk.rate;
176+
uint64_t aacSamples = (packTime/90) * freq / 1000;
177+
//round to nearest packet, assuming all 1024 samples (probably wrong, but meh)
178+
aacSamples += 512;
179+
aacSamples /= 1024;
180+
aacSamples *= 1024;
181+
//Get closest 90kHz clock time to perfect sample alignment
182+
packTime = aacSamples * 90000 / freq;
182183
}
183184
bs = TS::Packet::getPESAudioLeadIn(tempLen, packTime, Trk.bps);
184185
fillPacket(bs.data(), bs.size(), firstPack, video, keyframe, pkgPid, contPkg);

src/output/output_ts_base.h

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace Mist {
2525
int contSDT;
2626
unsigned int packCounter; ///\todo update constructors?
2727
TS::Packet packData;
28-
bool appleCompat;
2928
uint64_t sendRepeatingHeaders; ///< Amount of ms between PAT/PMT. Zero means do not repeat.
3029
uint64_t lastHeaderTime; ///< Timestamp last PAT/PMT were sent.
3130
uint64_t ts_from; ///< Starting time to subtract from timestamps

0 commit comments

Comments
 (0)