Changeset 102
- Timestamp:
- 08/24/10 19:27:38 (18 months ago)
- Location:
- trunk/sources
- Files:
-
- 11 edited
-
androidapplestreaming/include/api.h (modified) (1 diff)
-
androidapplestreaming/include/jniwrapper.h (modified) (1 diff)
-
androidapplestreaming/src/api.cpp (modified) (1 diff)
-
androidapplestreaming/src/jniwrapper.cpp (modified) (1 diff)
-
androidapplestreaming/src/main.cpp (modified) (1 diff)
-
applications/applestreamingclient/include/clientcontext.h (modified) (2 diffs)
-
applications/applestreamingclient/include/protocols/variant/messagestructure.h (modified) (4 diffs)
-
applications/applestreamingclient/include/protocols/variant/variantappprotocolhandler.h (modified) (1 diff)
-
applications/applestreamingclient/src/clientcontext.cpp (modified) (5 diffs)
-
applications/applestreamingclient/src/protocols/variant/variantappprotocolhandler.cpp (modified) (2 diffs)
-
thelib/src/protocols/rtp/connectivity/outboundconnectivity.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/androidapplestreaming/include/api.h
r90 r102 37 37 Variant ContextCloseAll(); 38 38 39 Variant CommandSetBitrates(uint32_t contextId, string bitRates); 39 40 Variant CommandPlay(uint32_t contextId, string connectingString); 40 41 Variant CommandPlay(uint32_t contextId, string m3u8Uri, string httpSessionId, -
trunk/sources/androidapplestreaming/include/jniwrapper.h
r90 r102 45 45 extern "C" jobject Java_com_rtmpd_CommandsInterface_ContextCloseAll( 46 46 JNIEnv* pEnv, jobject thiz); 47 extern "C" jobject Java_com_rtmpd_CommandsInterface_CommandSetBitrates( 48 JNIEnv* pEnv, jobject thiz, jint contextId, jstring bitrates); 47 49 extern "C" jobject Java_com_rtmpd_CommandsInterface_CommandPlay( 48 50 JNIEnv* pEnv, jobject thiz, jint contextId, jstring m3u8Uri, -
trunk/sources/androidapplestreaming/src/api.cpp
r96 r102 253 253 } 254 254 255 Variant CommandSetBitrates(uint32_t contextId, string bitRates) { 256 replace(bitRates, "[", ""); 257 replace(bitRates, "]", ""); 258 vector<string> parts; 259 split(bitRates, ",", parts); 260 261 vector<uint32_t> bws; 262 for (uint32_t i = 0; i < parts.size(); i++) { 263 string strBw = parts[i]; 264 trim(strBw); 265 if (strBw == "") 266 continue; 267 uint32_t bw = (uint32_t) atol(STR(strBw)); 268 ADD_VECTOR_END(bws, bw); 269 } 270 271 Variant request; 272 ASC_REQ_BUILD_COMMAND_SET_BITRATES(request, contextId, bws); 273 Variant response; 274 SEND_VARIANT_REQUEST(request, response); 275 return response; 276 } 277 255 278 Variant CommandPlay(uint32_t contextId, string connectingString) { 256 279 vector<string> parts; -
trunk/sources/androidapplestreaming/src/jniwrapper.cpp
r90 r102 80 80 } 81 81 82 extern "C" jobject Java_com_rtmpd_CommandsInterface_CommandSetBitrates( 83 JNIEnv* pEnv, jobject thiz, jint contextId, jstring bitrates) { 84 Variant result = CommandSetBitrates( 85 (uint32_t) contextId, 86 pEnv->GetStringUTFChars(bitrates, NULL)); 87 return VariantToJObject(result, pEnv); 88 } 89 82 90 extern "C" jobject Java_com_rtmpd_CommandsInterface_CommandPlay( 83 91 JNIEnv* pEnv, jobject thiz, jint contextId, jstring m3u8Uri, -
trunk/sources/androidapplestreaming/src/main.cpp
r96 r102 124 124 125 125 uint32_t contextId = (uint32_t) ASC_RES_PARAM(result, "contextId"); 126 result = CommandSetBitrates(contextId, " [800000]"); 127 FINEST("result:\n%s", STR(result.ToString())); 128 126 129 result = CommandPlay(contextId, MY_URL, MY_SESSION_ID, MY_KEY); 127 130 FINEST("result:\n%s", STR(result.ToString())); -
trunk/sources/applications/applestreamingclient/include/clientcontext.h
r96 r102 70 70 StreamsManager *_pStreamsManager; 71 71 double _lastWallClock; 72 map<uint32_t, uint32_t> _allowedBitrates; 72 73 private: 73 74 ClientContext(); … … 101 102 uint32_t GetCurrentChunkIndex(); 102 103 AppleStreamingClientApplication *GetApplication(); 104 void SetAllowedBitrates(map<uint32_t, uint32_t> allowedBitrates); 103 105 104 106 //processing -
trunk/sources/applications/applestreamingclient/include/protocols/variant/messagestructure.h
r80 r102 29 29 30 30 #define ASC_REQ_TYPE_COMMAND_PLAY "commandPlay" 31 #define ASC_REQ_TYPE_COMMAND_SET_BITRATES "commandSetBitrates" 31 32 #define ASC_REQ_TYPE_COMMAND_PAUSE "commandPause" 32 33 #define ASC_REQ_TYPE_COMMAND_RESUME "commandResume" … … 40 41 #define ASC_REQ_TYPE_INFO_PLAYBACK "infoPlayback" 41 42 43 #define ASC_REQ_COMMAND_SET_BITRATES_BITRATES "bitrates" 42 44 #define ASC_REQ_COMMAND_PLAY_URI_KEY "uri" 43 45 #define ASC_REQ_COMMAND_PLAY_SESSION_ID_KEY "sessionId" … … 88 90 #define ASC_REQ_PARAMS(v) ASC_REQ(v)["parameters"] 89 91 #define ASC_REQ_PARAM(v,key) ASC_REQ_PARAMS(v)[(key)] 92 #define ASC_REQ_COMMAND_SET_BITRATES_BWS(v) ASC_REQ_PARAM(v,ASC_REQ_COMMAND_SET_BITRATES_BITRATES) 90 93 #define ASC_REQ_COMMAND_PLAY_URI(v) ASC_REQ_PARAM(v,ASC_REQ_COMMAND_PLAY_URI_KEY) 91 94 #define ASC_REQ_COMMAND_PLAY_SESSION_ID(v) ASC_REQ_PARAM(v,ASC_REQ_COMMAND_PLAY_SESSION_ID_KEY) … … 126 129 ASC_REQ_BUILD(v,ASC_REQ_TYPE_CONTEXT_CLOSE_ALL,0,Variant()) 127 130 131 #define ASC_REQ_BUILD_COMMAND_SET_BITRATES(v,contextId,bws) \ 132 do { \ 133 Variant parameters; \ 134 parameters[ASC_REQ_COMMAND_SET_BITRATES_BITRATES].IsArray(true); \ 135 for(uint32_t i=0;i<bws.size();i++) { \ 136 parameters[ASC_REQ_COMMAND_SET_BITRATES_BITRATES].PushToArray((uint32_t)bws[i]); \ 137 } \ 138 ASC_REQ_BUILD(v,ASC_REQ_TYPE_COMMAND_SET_BITRATES,contextId,parameters); \ 139 } while(0) 140 128 141 #define ASC_REQ_BUILD_COMMAND_PLAY(v,contextId,uri,sessionId,keyPassword) \ 129 142 do { \ -
trunk/sources/applications/applestreamingclient/include/protocols/variant/variantappprotocolhandler.h
r74 r102 39 39 void ProcessContextClose(BaseVariantProtocol *pProtocol, Variant &request); 40 40 void ProcessContextCloseAll(BaseVariantProtocol *pProtocol, Variant &request); 41 void ProcessCommandSetBitrates(BaseVariantProtocol *pProtocol, Variant &request); 41 42 void ProcessCommandPlay(BaseVariantProtocol *pProtocol, Variant &request); 42 43 void ProcessCommandPause(BaseVariantProtocol *pProtocol, Variant &request); -
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; -
trunk/sources/applications/applestreamingclient/src/protocols/variant/variantappprotocolhandler.cpp
r80 r102 70 70 } else if (type == ASC_REQ_TYPE_COMMAND_PLAY) { 71 71 ProcessCommandPlay(pProtocol, lastReceived); 72 } else if (type == ASC_REQ_TYPE_COMMAND_SET_BITRATES) { 73 ProcessCommandSetBitrates(pProtocol, lastReceived); 72 74 } else if (type == ASC_REQ_TYPE_COMMAND_PAUSE) { 73 75 ProcessCommandPause(pProtocol, lastReceived); … … 116 118 BaseVariantProtocol *pProtocol, Variant &request) { 117 119 ((AppleStreamingClientApplication *) GetApplication())->CloseAllContexts(); 120 ASC_RES_BUILD_OK(request, Variant()); 121 } 122 123 void VariantAppProtocolHandler::ProcessCommandSetBitrates( 124 BaseVariantProtocol *pProtocol, Variant &request) { 125 GET_CONTEXT(pProtocol, request); 126 map<uint32_t, uint32_t> bws; 127 128 FOR_MAP(ASC_REQ_COMMAND_SET_BITRATES_BWS(request), string, Variant, i) { 129 FINEST("(uint32_t)MAP_VAL(i): %d", (uint32_t) MAP_VAL(i)); 130 bws[(uint32_t) MAP_VAL(i)] = (uint32_t) MAP_VAL(i); 131 } 132 pContext->SetAllowedBitrates(bws); 118 133 ASC_RES_BUILD_OK(request, Variant()); 119 134 } -
trunk/sources/thelib/src/protocols/rtp/connectivity/outboundconnectivity.cpp
r96 r102 423 423 424 424 //6. RTP 425 FINEST("rate: %d", rate);425 //FINEST("rate: %d", rate); 426 426 double rtpDouble = ((currentTime - _startupTime) / (double) CLOCKS_PER_SEC) * rate; 427 FINEST("rtpDouble: %.2f", rtpDouble);427 //FINEST("rtpDouble: %.2f", rtpDouble); 428 428 uint32_t rtp = (uint32_t) rtpDouble; 429 FINEST("rtp: %d", rtp); 429 //FINEST("rtp: %d", rtp); 430 //uint32_t packetRtp = ntohlp(pSrc + 4); 431 //FINEST("packetRtp: %d", packetRtp); 432 //FINEST("diff: %.0f", (double) packetRtp - (double) rtp); 430 433 put_htonl(pDest + 16, rtp); 431 434 //memcpy(pDest + 16, pSrc + 4, 4);
Note: See TracChangeset
for help on using the changeset viewer.
