- Timestamp:
- 08/24/10 20:27:38 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/applications/applestreamingclient/src/clientcontext.cpp
r96 r102 219 219 } 220 220 221 void ClientContext::SetAllowedBitrates(map<uint32_t, uint32_t> allowedBitrates) { 222 _allowedBitrates = allowedBitrates; 223 } 224 221 225 bool ClientContext::StartProcessing() { 222 226 //1. Parse the connecting string and split it into usable pieces … … 283 287 Playlist *pPlaylist = _childPlaylists[optimalBw]; 284 288 285 if (_currentItemIndex == 0)286 _currentItemIndex = pPlaylist->GetItemsCount() / 2 + 10;289 // if (_currentItemIndex == 0) 290 // _currentItemIndex = pPlaylist->GetItemsCount() / 2 + 10; 287 291 288 292 //4. Is this the last item in the playlis? … … 391 395 392 396 uint32_t ClientContext::GetOptimalBw() { 393 //if (_optimalBw == 0) {394 //_optimalBw = MAP_KEY(_childPlaylists.begin());395 //}396 _optimalBw = 800000;397 if (_optimalBw == 0) { 398 _optimalBw = MAP_KEY(_childPlaylists.begin()); 399 } 400 //_optimalBw = 800000; 397 401 return _optimalBw; 398 402 } … … 467 471 if (bw < 10000) 468 472 bw *= 1024; 473 if (_allowedBitrates.size() > 0) { 474 if (!MAP_HAS1(_allowedBitrates, bw)) { 475 WARN("Skipping bitrate %d", bw); 476 continue; 477 } 478 } 469 479 string uri = _pMasterPlaylist->GetItemUri(i); 470 480 … … 530 540 531 541 bool ClientContext::SignalSpeedDetected(double instantAmount, double instantTime) { 532 // FINEST("instantAmount: %.2f; instantTime: %.8f; Speed: %.2f KB/s", 533 // instantAmount, instantTime, instantAmount / instantTime / 1024); 534 _pSpeedComputer->PushAmount(instantAmount, instantTime); 535 double meanSpeed = _pSpeedComputer->GetMeanSpeed(); 536 537 uint32_t before = _optimalBw; 538 meanSpeed *= 8.0; 539 // if (((aaa++) % 200) == 0) { 540 // double ms = meanSpeed / 1024.00 / 8; 541 // string um = "KB/s"; 542 // if (ms > 1024) { 543 // ms = ms / 1024.00; 544 // um = "MB/s"; 542 // // FINEST("instantAmount: %.2f; instantTime: %.8f; Speed: %.2f KB/s", 543 // // instantAmount, instantTime, instantAmount / instantTime / 1024); 544 // _pSpeedComputer->PushAmount(instantAmount, instantTime); 545 // double meanSpeed = _pSpeedComputer->GetMeanSpeed(); 546 // 547 // uint32_t before = _optimalBw; 548 // meanSpeed *= 8.0; 549 // // if (((aaa++) % 200) == 0) { 550 // // double ms = meanSpeed / 1024.00 / 8; 551 // // string um = "KB/s"; 552 // // if (ms > 1024) { 553 // // ms = ms / 1024.00; 554 // // um = "MB/s"; 555 // // } 556 // // //FINEST("Speed: %.2f %s", ms, STR(um)); 557 // // } 558 // 559 // _optimalBw = MAP_KEY(_childPlaylists.begin()); 560 // 561 // FOR_MAP(_childPlaylists, uint32_t, Playlist *, i) { 562 // uint32_t testBandwidth = MAP_KEY(i); 563 // //FINEST("meanSpeed: %.2f; testBandwidth: %.2f", meanSpeed, testBandwidth); 564 // if (meanSpeed > testBandwidth) { 565 // _optimalBw = testBandwidth; 545 566 // } 546 // //FINEST("Speed: %.2f %s", ms, STR(um));547 567 // } 548 549 _optimalBw = MAP_KEY(_childPlaylists.begin()); 550 551 FOR_MAP(_childPlaylists, uint32_t, Playlist *, i) { 552 uint32_t testBandwidth = MAP_KEY(i); 553 //FINEST("meanSpeed: %.2f; testBandwidth: %.2f", meanSpeed, testBandwidth); 554 if (meanSpeed > testBandwidth) { 555 _optimalBw = testBandwidth; 556 } 557 } 558 if (before != _optimalBw) { 559 if (before < _optimalBw) { 560 if (GETAVAILABLEBYTESCOUNT(_avData) < _maxAVBufferSize / 3) { 561 _optimalBw = before; 562 } else { 563 INFO("BW changed: before: %d; after: %d; speed: %.3f", 564 before, _optimalBw, meanSpeed); 565 } 566 } else { 567 INFO("BW changed: before: %d; after: %d; speed: %.3f", 568 before, _optimalBw, meanSpeed); 569 } 570 } 568 // if (before != _optimalBw) { 569 // if (before < _optimalBw) { 570 // if (GETAVAILABLEBYTESCOUNT(_avData) < _maxAVBufferSize / 3) { 571 // _optimalBw = before; 572 // } else { 573 // INFO("BW changed: before: %d; after: %d; speed: %.3f", 574 // before, _optimalBw, meanSpeed); 575 // } 576 // } else { 577 // INFO("BW changed: before: %d; after: %d; speed: %.3f", 578 // before, _optimalBw, meanSpeed); 579 // } 580 // } 571 581 572 582 return true;
Note: See TracChangeset
for help on using the changeset viewer.
