Changeset 80


Ignore:
Timestamp:
08/17/10 12:54:17 (18 months ago)
Author:
shiretu
Message:

-- work on applestreamingclient

Location:
trunk/sources/applications/applestreamingclient
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/applications/applestreamingclient/flex/src/applestreamingclient.mxml

    r2 r80  
    1111                         
    1212                        import mx.controls.Alert; 
     13                        import mx.utils.ObjectUtil; 
     14                         
     15                        import org.osmf.net.dynamicstreaming.SufficientBandwidthRule; 
    1316                         
    1417                        private var _connectData:Object; 
    1518                        [Bindable] 
    1619                        private var _connection:Engine; 
     20                        private var _bwInfoTimer:Timer; 
    1721                         
    1822                        private function Init():void{ 
     
    2731                                player.Initialize(); 
    2832                                ConnectDisconnect(); 
     33                                pnlInfo.x=player.x; 
     34                                pnlInfo.y=player.y+player.height-pnlInfo.height; 
     35                                _bwInfoTimer = new Timer(1000); 
     36                                _bwInfoTimer.addEventListener(TimerEvent.TIMER,ShowBwInfo); 
     37                                txtAppleConnectingString.text="http://mlbvod-akc.mlb.com/mlbam/2010/04/08/MLB_GAME_VIDEO_LANPIT_HOME_20100408/master_wired.m3u8|bl8D2EASEF8WUrzZ+y3o0NiQyAk=|playback=HTTP_CLOUD_WIRED&contentId=7320085&appAccountName=mlb&eventId=14-263849-2010-04-08&ipid=11627706&sessionKey=GBncPsxRBV02IC9n80RP1Sdr9ew%3D"; 
     38                        } 
     39                         
     40                        private function ShowBwInfo(event:TimerEvent):void { 
     41                                _connection.Call("getBWInfo",BWInfoAvaliable); 
     42                        } 
     43                         
     44                        private function BWInfoAvaliable(info:Object):void{ 
     45                                if(info==null) 
     46                                        return; 
     47                                lblAvalivaleBws.text=""; 
     48                                for(var i:int=0;i<info.response.parameters.availableBws.length;i++){ 
     49                                        lblAvalivaleBws.text+=prettyPrint(info.response.parameters.availableBws[i]/8,"/s")+", "; 
     50                                } 
     51                                lblDetectedBw.text=prettyPrint(info.response.parameters.detectedBw/8,"/s"); 
     52                                lblSelectedBw.text=prettyPrint(info.response.parameters.selectedBw/8,"/s");; 
     53                                lblBufferLevel.text=prettyPrint(info.response.parameters.bufferLevel); 
     54                                lblMaxBufferLevel.text=prettyPrint(info.response.parameters.bufferMaxLevel); 
     55                                lblBufferLevelPercent.text=info.response.parameters.bufferLevelPercent.toPrecision(3)+"%"; 
     56                                lblBufferLevelSeconds.text=(info.response.parameters.bufferLevel/info.response.parameters.selectedBw*8).toPrecision(3)+" s"; 
     57                        } 
     58                         
     59                        private function prettyPrint(val:Number, suffix:String=""):String{ 
     60                                var result:String=""; 
     61                                var um:String="B"+suffix; 
     62                                if(val>1024){ 
     63                                        val=val/1024; 
     64                                        um="KB"+suffix; 
     65                                } 
     66                                if(val>1024){ 
     67                                        val=val/1024; 
     68                                        um="MB"+suffix; 
     69                                } 
     70                                result=val.toPrecision(4)+" "+um; 
     71                                return result; 
    2972                        } 
    3073                         
     
    3982                                } else { 
    4083                                        _connection.Disconnect(); 
     84                                        if(_bwInfoTimer!=null) 
     85                                                _bwInfoTimer.stop(); 
    4186                                } 
    4287                        } 
     
    5398                                //                              player.Play(_connection,_connection.TSStreams[dgFlvs.selectedIndex].data); 
    5499                                _connection.Call("setupStream",null,txtAppleConnectingString.text); 
     100                                _bwInfoTimer.start(); 
    55101                        } 
    56102                ]]> 
    57103        </mx:Script> 
    58         <mx:VBox paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10" borderStyle="solid" width="100%" height="100%"> 
     104        <mx:VBox id="vBox" paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10" borderStyle="solid" width="100%" height="100%"> 
    59105                <mx:HBox width="100%"> 
    60106                        <mx:Button label="Show logs..." id="btnLogs" click="LogsWindow.Show(this);"/> 
     
    65111                        <mx:TextInput text="" id="txtAppleConnectingString" width="100%"/> 
    66112                </mx:HBox> 
    67                 <ns1:VideoPlayer width="100%" height="100%" id="player"/> 
     113                <ns1:VideoPlayer width="100%" height="100%" id="player" enabled="{_connection.IsConnected}" /> 
    68114        </mx:VBox> 
     115        <mx:Panel id="pnlInfo" width="500" x="10" y="267" title="Bandwidth info"> 
     116                <mx:VBox width="100%" height="100%"> 
     117                        <mx:HBox width="100%" borderStyle="solid"> 
     118                                <mx:Label text="Available bws:" width="50%"/> 
     119                                <mx:Label id="lblAvalivaleBws" width="50%"/> 
     120                        </mx:HBox> 
     121                        <mx:HBox width="100%" borderStyle="solid"> 
     122                                <mx:Label text="Detected bw:" width="50%"/> 
     123                                <mx:Label id="lblDetectedBw" width="50%"/> 
     124                        </mx:HBox> 
     125                        <mx:HBox width="100%" borderStyle="solid"> 
     126                                <mx:Label text="Selected bw:" width="50%"/> 
     127                                <mx:Label id="lblSelectedBw" width="50%"/> 
     128                        </mx:HBox> 
     129                        <mx:HBox width="100%" borderStyle="solid"> 
     130                                <mx:Label text="Buffer level:" width="50%"/> 
     131                                <mx:Label id="lblBufferLevel" width="50%"/> 
     132                        </mx:HBox> 
     133                        <mx:HBox width="100%" borderStyle="solid"> 
     134                                <mx:Label text="Max buffer level:" width="50%"/> 
     135                                <mx:Label id="lblMaxBufferLevel" width="50%"/> 
     136                        </mx:HBox> 
     137                        <mx:HBox width="100%" borderStyle="solid"> 
     138                                <mx:Label text="Buffer level percent:" width="50%"/> 
     139                                <mx:Label id="lblBufferLevelPercent" width="50%"/> 
     140                        </mx:HBox> 
     141                        <mx:HBox width="100%" borderStyle="solid"> 
     142                                <mx:Label text="Buffer level seconds:" width="50%"/> 
     143                                <mx:Label id="lblBufferLevelSeconds" width="50%"/> 
     144                        </mx:HBox> 
     145                </mx:VBox> 
     146        </mx:Panel> 
    69147</mx:Application> 
  • trunk/sources/applications/applestreamingclient/include/clientcontext.h

    r74 r80  
    9494        uint32_t GetMaxBufferLevel(); 
    9595        double GetBufferLevelPercent(); 
     96        double GetMinTimestamp(); 
     97        double GetMaxTimestamp(); 
     98        uint32_t GetChunksCount(); 
     99        double GetCurrentTimestamp(); 
     100        uint32_t GetCurrentChunkIndex(); 
    96101 
    97102        //processing 
  • trunk/sources/applications/applestreamingclient/include/protocols/rtmp/rtmpappprotocolhandler.h

    r36 r80  
    4141        bool ProcessSetupStream(BaseRTMPProtocol *pFrom, 
    4242                        Variant &request); 
     43        bool ProcessGetBWInfo(BaseRTMPProtocol *pFrom, 
     44                        Variant &request); 
    4345}; 
    4446 
  • trunk/sources/applications/applestreamingclient/include/protocols/variant/messagestructure.h

    r74 r80  
    5555#define ASC_RES_INFO_BANDWIDTH_MAX_BUFFER_LEVEL                 "bufferMaxLevel" 
    5656#define ASC_RES_INFO_BANDWIDTH_MAX_BUFFER_LEVEL_PERCENT "bufferLevelPercent" 
     57#define ASC_RES_INFO_PLAYBACK_MIN_TS                                    "minTs" 
     58#define ASC_RES_INFO_PLAYBACK_MAX_TS                                    "maxTs" 
     59#define ASC_RES_INFO_PLAYBACK_CHUNKS_COUNT                              "chunksCount" 
     60#define ASC_RES_INFO_PLAYBACK_CURRENT_CHUNK                             "currentChunk" 
     61#define ASC_RES_INFO_PLAYBACK_CURRENT_TS                                "currentTs" 
    5762 
    5863#define ASC_RES_STATUS_OK                                                       0 
     
    276281} while(0) 
    277282 
     283#define ASC_RES_BUILD_OK_INFO_PLAYBACK(r,minTs, maxTs, chunksCount, currentTs, currentChunk) \ 
     284do { \ 
     285        Variant params; \ 
     286        params[ASC_RES_INFO_PLAYBACK_MIN_TS]=(double)(minTs); \ 
     287        params[ASC_RES_INFO_PLAYBACK_MAX_TS]=(double)(maxTs); \ 
     288        params[ASC_RES_INFO_PLAYBACK_CHUNKS_COUNT]=(uint32_t)(chunksCount); \ 
     289        params[ASC_RES_INFO_PLAYBACK_CURRENT_CHUNK]=(uint32_t)(currentChunk); \ 
     290        params[ASC_RES_INFO_PLAYBACK_CURRENT_TS]=(double)(currentTs); \ 
     291        ASC_RES_BUILD(r,ASC_RES_STATUS_OK,params); \ 
     292} while(0) 
     293 
    278294#endif  /* _MESSAGESTRUCTURE_H */ 
    279295 
  • trunk/sources/applications/applestreamingclient/src/clientcontext.cpp

    r74 r80  
    5353        _lastWallClock = 0; 
    5454        _lastStreamClock = 0; 
     55        _avData.EnsureSize(_maxAVBufferSize * 3); 
    5556        INFO("Context created: %d (%p)", _id, this); 
    5657} 
     
    180181} 
    181182 
     183double ClientContext::GetMinTimestamp() { 
     184        return 0; 
     185} 
     186 
     187double ClientContext::GetMaxTimestamp() { 
     188        return 0; 
     189} 
     190 
     191uint32_t ClientContext::GetChunksCount() { 
     192        return 0; 
     193} 
     194 
     195double ClientContext::GetCurrentTimestamp() { 
     196        return 0; 
     197} 
     198 
     199uint32_t ClientContext::GetCurrentChunkIndex() { 
     200        return 0; 
     201} 
     202 
    182203bool ClientContext::StartProcessing() { 
    183204        //1. Parse the connecting string and split it into usable pieces 
     
    486507        } 
    487508        if (before != _optimalBw) { 
    488                 INFO("BW changed: before: %d; after: %d; speed: %.3f", 
    489                                 before, _optimalBw, meanSpeed); 
    490                 //, STR(Bandwidths().ToString())) 
     509                if (before < _optimalBw) { 
     510                        if (GETAVAILABLEBYTESCOUNT(_avData) < _maxAVBufferSize / 3) { 
     511                                _optimalBw = before; 
     512                        } else { 
     513                                INFO("BW changed: before: %d; after: %d; speed: %.3f", 
     514                                                before, _optimalBw, meanSpeed); 
     515                        } 
     516                } else { 
     517                        INFO("BW changed: before: %d; after: %d; speed: %.3f", 
     518                                        before, _optimalBw, meanSpeed); 
     519                } 
    491520        } 
    492521 
  • trunk/sources/applications/applestreamingclient/src/protocols/rtmp/rtmpappprotocolhandler.cpp

    r56 r80  
    2626#include "application/baseclientapplication.h" 
    2727#include "eventsink/rtmpeventsink.h" 
     28#include "protocols/variant/messagestructure.h" 
     29#include "protocols/rtmp/messagefactories/genericmessagefactory.h" 
    2830 
    2931RTMPAppProtocolHandler::RTMPAppProtocolHandler(Variant &configuration) 
     
    4547        if (functionName == "setupStream") { 
    4648                return ProcessSetupStream(pFrom, request); 
     49        } else if (functionName == "getBWInfo") { 
     50                return ProcessGetBWInfo(pFrom, request); 
    4751        } else { 
    4852                WARN("Invalid function name"); 
     
    8892        return pContext->StartProcessing(); 
    8993} 
     94 
     95bool RTMPAppProtocolHandler::ProcessGetBWInfo(BaseRTMPProtocol *pFrom, 
     96                Variant &request) { 
     97        uint32_t contextId = pFrom->GetCustomParameters()["contextId"]; 
     98        Variant response; 
     99        Variant parameters; 
     100        parameters.PushToArray(Variant()); 
     101        parameters.PushToArray(Variant()); 
     102        if (contextId == 0) { 
     103                WARN("No context available yet"); 
     104                response = GenericMessageFactory::GetInvokeResult(request, parameters); 
     105                return SendRTMPMessage(pFrom, response); 
     106        } 
     107        ClientContext *pContext = ClientContext::GetContext(contextId, 
     108                        GetApplication()->GetId(), pFrom->GetType()); 
     109        if (pContext == NULL) { 
     110                FATAL("Unable to get context"); 
     111                return false; 
     112        } 
     113 
     114 
     115        ASC_RES_BUILD_OK_INFO_BANDWIDTH(parameters[(uint32_t) 1], 
     116                        pContext->GetAvailableBandwidths(), 
     117                        pContext->GetDetectedBandwidth(), 
     118                        pContext->GetSelectedBandwidth(), 
     119                        pContext->GetBufferLevel(), 
     120                        pContext->GetMaxBufferLevel(), 
     121                        pContext->GetBufferLevelPercent()); 
     122        response = GenericMessageFactory::GetInvokeResult(request, parameters); 
     123        return SendRTMPMessage(pFrom, response); 
     124} 
     125 
    90126#endif /* HAS_PROTOCOL_RTMP */ 
  • trunk/sources/applications/applestreamingclient/src/protocols/variant/variantappprotocolhandler.cpp

    r74 r80  
    200200                BaseVariantProtocol *pProtocol, Variant &request) { 
    201201        GET_CONTEXT(pProtocol, request); 
    202         /* 
    203          * seek range 
    204          * current position 
    205          */ 
    206         //      ASC_RES_BUILD_OK_INFO_PLAYBACK(request, 
    207         //                      pContext->GetMinTimestamp(), 
    208         //                      pContext->GetMaxTimestamp(), 
    209         //                      pContext->GetChunksCount(), 
    210         //                      pContext->GetCurrentTimestamp(), 
    211         //                      pContext->GetCurrentChunkIndex()); 
    212         ASC_RES_BUILD_NYI(request); 
    213 } 
     202        ASC_RES_BUILD_OK_INFO_PLAYBACK(request, 
     203                        pContext->GetMinTimestamp(), 
     204                        pContext->GetMaxTimestamp(), 
     205                        pContext->GetChunksCount(), 
     206                        pContext->GetCurrentTimestamp(), 
     207                        pContext->GetCurrentChunkIndex()); 
     208} 
Note: See TracChangeset for help on using the changeset viewer.