Changeset 104
- Timestamp:
- 08/24/10 23:20:41 (18 months ago)
- Location:
- trunk/sources/applications/applestreamingclient
- Files:
-
- 4 edited
-
include/clientcontext.h (modified) (3 diffs)
-
include/playlist.h (modified) (1 diff)
-
src/clientcontext.cpp (modified) (5 diffs)
-
src/playlist.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/applications/applestreamingclient/include/clientcontext.h
r103 r104 59 59 uint32_t _tsId; 60 60 uint32_t _parsedChildPlaylistsCount; 61 uint32_t _current ItemIndex;61 uint32_t _currentSequence; 62 62 uint32_t _optimalBw; 63 63 uint32_t _lastUsedBw; … … 71 71 double _lastWallClock; 72 72 map<uint32_t, uint32_t> _allowedBitrates; 73 map<uint32_t, uint32_t> _mediaSequences;74 73 private: 75 74 ClientContext(); … … 125 124 bool ConsumeAVBuffer(); 126 125 private: 127 bool ReloadPlaylist(uint32_t bw);128 126 uint32_t GetOptimalBw(); 129 127 bool ParseConnectingString(); -
trunk/sources/applications/applestreamingclient/include/playlist.h
r103 r104 54 54 Variant & GetCustomData(); 55 55 uint32_t GetItemsCount(); 56 string GetItemUri(uint32_t index); 57 string GetItemKeyUri(uint32_t index); 58 uint32_t GetItemMediaSequence(uint32_t index); 59 uint32_t GetItemBandwidth(uint32_t index); 60 Variant GetItemVariant(uint32_t index); 61 void ApproximateStartEndTimes(uint32_t index, double start, double end); 62 void GetSeekRange(double &min, double &max); 63 uint32_t GetItemIndex(double seekPoint); 64 uint32_t GetLastMediaSequence(); 56 string GetItemUri(uint32_t &sequence); 57 string GetItemKeyUri(uint32_t &sequence); 58 uint32_t GetItemBandwidth(uint32_t &sequence); 59 Variant GetItemVariant(uint32_t &sequence); 60 private: 61 uint32_t GetIndex(uint32_t &sequence); 65 62 }; 66 63 -
trunk/sources/applications/applestreamingclient/src/clientcontext.cpp
r103 r104 44 44 _pMasterPlaylist = NULL; 45 45 _parsedChildPlaylistsCount = 0; 46 _current ItemIndex= 0;46 _currentSequence = 0; 47 47 _optimalBw = 0; 48 48 _lastUsedBw = 0; … … 291 291 292 292 //4. Is this the last item in the playlis? 293 FINEST("---------------------------------------------------"); 294 if (_currentItemIndex >= pPlaylist->GetItemsCount()) { 295 if (ReloadPlaylist(optimalBw)) { 296 WARN("End of list. Wait one sec and try again"); 297 FINEST("---------------------------------------------------"); 298 return EnqueueFetchChildPlaylist(_childPlaylists[optimalBw]->GetPlaylistUri(), optimalBw); 299 } else { 300 WARN("No playlist reload"); 301 _currentItemIndex--; 302 } 303 } 304 FINEST("_currentItemIndex: %d", _currentItemIndex); 305 FINEST("---------------------------------------------------"); 293 string uri = pPlaylist->GetItemUri(_currentSequence); 294 if (uri == "") { 295 FINEST("---------------------------------------------------"); 296 WARN("End of list. Wait one sec and try again"); 297 FINEST("---------------------------------------------------"); 298 return EnqueueFetchChildPlaylist(_childPlaylists[optimalBw]->GetPlaylistUri(), optimalBw); 299 } 306 300 307 301 //4. Get the item URI and the key URI if available 308 string uri = pPlaylist->GetItemUri(_currentItemIndex); 309 string keyUri = pPlaylist->GetItemKeyUri(_currentItemIndex); 310 _mediaSequences[optimalBw] = pPlaylist->GetItemMediaSequence(_currentItemIndex); 302 string keyUri = pPlaylist->GetItemKeyUri(_currentSequence); 311 303 if (keyUri != "") 312 304 keyUri += "&" + _connectingString.sessionId; … … 402 394 //7. Done 403 395 return true; 404 }405 406 bool ClientContext::ReloadPlaylist(uint32_t bw) {407 if (!MAP_HAS1(_mediaSequences, bw)) {408 FINEST("bw %d not in _mediaSequences", bw);409 return true;410 }411 if (!MAP_HAS1(_childPlaylists, bw)) {412 FINEST("bw %d not in playlists", bw);413 return true;414 }415 416 uint32_t lastSequence = _mediaSequences[bw];417 FINEST("lastSequence: %d", lastSequence);418 uint32_t playlistSequnece = _childPlaylists[bw]->GetLastMediaSequence();419 FINEST("playlistSequnece: %d", playlistSequnece);420 421 return lastSequence == playlistSequnece;422 396 } 423 397 … … 547 521 string itemUri = parameters["payload"]["itemUri"]; 548 522 uint32_t bw = parameters["payload"]["bw"]; 549 uint64_t iv = _c hildPlaylists[bw]->GetItemMediaSequence(_currentItemIndex);523 uint64_t iv = _currentSequence; 550 524 //FINEST("itemUri: %s; bw: %d; key: %s", STR(itemUri), bw, STR(key)); 551 525 … … 563 537 564 538 bool ClientContext::SignalTSChunkComplete(uint32_t bw) { 565 _current ItemIndex++;539 _currentSequence++; 566 540 return StartFeeding(); 567 541 } -
trunk/sources/applications/applestreamingclient/src/playlist.cpp
r103 r104 128 128 //that means the item is finished. Save it 129 129 _items[itemIndex] = item; 130 _itemMediaSequences[ itemIndex] = _lastMediaSequence;130 _itemMediaSequences[_lastMediaSequence] = itemIndex; 131 131 _itemKeyUris[itemIndex] = _pLastKeyUri; 132 132 _itemUris[itemIndex] = pLine; … … 189 189 } 190 190 191 string Playlist::GetItemUri(uint32_t index) { 191 string Playlist::GetItemUri(uint32_t &sequence) { 192 uint32_t index = GetIndex(sequence); 192 193 if (index >= _itemUris.size()) 193 194 return ""; … … 203 204 } 204 205 205 string Playlist::GetItemKeyUri(uint32_t index) { 206 string Playlist::GetItemKeyUri(uint32_t &sequence) { 207 uint32_t index = GetIndex(sequence); 206 208 if (index >= _itemKeyUris.size()) 207 209 return ""; … … 211 213 } 212 214 213 uint32_t Playlist::GetItemMediaSequence(uint32_t index) { 214 if (index >= _itemMediaSequences.size()) 215 return 0; 216 return _itemMediaSequences[index]; 217 } 218 219 uint32_t Playlist::GetItemBandwidth(uint32_t index) { 215 uint32_t Playlist::GetItemBandwidth(uint32_t &sequence) { 216 uint32_t index = GetIndex(sequence); 220 217 if (index >= _itemBandwidths.size()) 221 218 return 0; … … 223 220 } 224 221 225 Variant Playlist::GetItemVariant(uint32_t index) { 226 if (index >= _items.size()) 227 return Variant(); 222 Variant Playlist::GetItemVariant(uint32_t &sequence) { 223 uint32_t index = GetIndex(sequence); 228 224 Variant result; 229 225 result["encryptionKeyUri"] = GetItemKeyUri(index); … … 233 229 } 234 230 235 void Playlist::ApproximateStartEndTimes(uint32_t index, double start, double end) { 236 _meanDuration = _meanDuration * (double) _meanDurationCount + end - start; 237 _meanDurationCount++; 238 _meanDuration /= (double) _meanDurationCount; 239 } 240 241 void Playlist::GetSeekRange(double &min, double &max) { 242 min = 0; 243 max = (double) _items.size() * _meanDuration; 244 } 245 246 uint32_t Playlist::GetItemIndex(double seekPoint) { 247 if (_meanDuration == 0) 248 return 0; 249 uint32_t index = (uint32_t) (seekPoint / _meanDuration); 250 if (_items.size() <= index) 251 return 0; 252 return index; 253 } 254 255 uint32_t Playlist::GetLastMediaSequence() { 256 if (_itemMediaSequences.size() == 0) 257 return 0; 258 return _itemMediaSequences[_itemMediaSequences.size() - 1]; 259 } 231 uint32_t Playlist::GetIndex(uint32_t &sequence) { 232 FINEST("---------------------"); 233 FINEST("sequence requested: %d", sequence); 234 //1. We have it, we return it 235 if (MAP_HAS1(_itemMediaSequences, sequence)) { 236 FINEST("WE have it"); 237 FINEST("---------------------"); 238 return _itemMediaSequences[sequence]; 239 } 240 241 //2. We don't have it, and is a 0 value, that means it was never initialized 242 if (sequence == 0) { 243 FINEST("sequence is 0"); 244 FINEST("_itemMediaSequences.size(): %d", _itemMediaSequences.size()); 245 if (_itemMediaSequences.size() != 0) { 246 //3. We have stuff. Init and return 247 FINEST("Return the first entry"); 248 sequence = MAP_KEY(_itemMediaSequences.begin()); 249 FINEST("---------------------"); 250 return MAP_VAL(_itemMediaSequences.begin()); 251 } else { 252 //4. We don't have stuff. Don't do nothing and return 253 FINEST("empty sequences"); 254 FINEST("---------------------"); 255 return 0xffffffff; 256 } 257 } 258 259 //5. Ok, sequence is initialized but we don't have that value. 260 //So, we search the next one, init and return; 261 FINEST("DISC????"); 262 if (_itemMediaSequences.size() > 0) { 263 FINEST("So, we have some items"); 264 if (MAP_KEY(_itemMediaSequences.end()) >= sequence) { 265 FINEST("Our sequence is somewhere there..."); 266 267 FOR_MAP(_itemMediaSequences, uint32_t, uint32_t, i) { 268 FINEST("sequence: %d; MAP_KEY(i): %d", sequence, MAP_KEY(i)); 269 if (MAP_KEY(i) >= sequence) { 270 sequence = MAP_KEY(i); 271 FINEST("JACKPOT"); 272 FINEST("---------------------"); 273 return MAP_VAL(i); 274 } 275 } 276 } else { 277 FINEST("sequence is bigger than the last item"); 278 } 279 } 280 281 //6. Nada. This is the bottom 282 FINEST("Nothing left to do...."); 283 FINEST("---------------------"); 284 return 0xffffffff; 285 }
Note: See TracChangeset
for help on using the changeset viewer.
