Changeset 104


Ignore:
Timestamp:
08/24/10 23:20:41 (18 months ago)
Author:
shiretu
Message:

-- fixed rolling file appender

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/applications/applestreamingclient/include/clientcontext.h

    r103 r104  
    5959        uint32_t _tsId; 
    6060        uint32_t _parsedChildPlaylistsCount; 
    61         uint32_t _currentItemIndex; 
     61        uint32_t _currentSequence; 
    6262        uint32_t _optimalBw; 
    6363        uint32_t _lastUsedBw; 
     
    7171        double _lastWallClock; 
    7272        map<uint32_t, uint32_t> _allowedBitrates; 
    73         map<uint32_t, uint32_t> _mediaSequences; 
    7473private: 
    7574        ClientContext(); 
     
    125124        bool ConsumeAVBuffer(); 
    126125private: 
    127         bool ReloadPlaylist(uint32_t bw); 
    128126        uint32_t GetOptimalBw(); 
    129127        bool ParseConnectingString(); 
  • trunk/sources/applications/applestreamingclient/include/playlist.h

    r103 r104  
    5454        Variant & GetCustomData(); 
    5555        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); 
     60private: 
     61        uint32_t GetIndex(uint32_t &sequence); 
    6562}; 
    6663 
  • trunk/sources/applications/applestreamingclient/src/clientcontext.cpp

    r103 r104  
    4444        _pMasterPlaylist = NULL; 
    4545        _parsedChildPlaylistsCount = 0; 
    46         _currentItemIndex = 0; 
     46        _currentSequence = 0; 
    4747        _optimalBw = 0; 
    4848        _lastUsedBw = 0; 
     
    291291 
    292292        //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        } 
    306300 
    307301        //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); 
    311303        if (keyUri != "") 
    312304                keyUri += "&" + _connectingString.sessionId; 
     
    402394        //7. Done 
    403395        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; 
    422396} 
    423397 
     
    547521        string itemUri = parameters["payload"]["itemUri"]; 
    548522        uint32_t bw = parameters["payload"]["bw"]; 
    549         uint64_t iv = _childPlaylists[bw]->GetItemMediaSequence(_currentItemIndex); 
     523        uint64_t iv = _currentSequence; 
    550524        //FINEST("itemUri: %s; bw: %d; key: %s", STR(itemUri), bw, STR(key)); 
    551525 
     
    563537 
    564538bool ClientContext::SignalTSChunkComplete(uint32_t bw) { 
    565         _currentItemIndex++; 
     539        _currentSequence++; 
    566540        return StartFeeding(); 
    567541} 
  • trunk/sources/applications/applestreamingclient/src/playlist.cpp

    r103 r104  
    128128                                //that means the item is finished. Save it 
    129129                                _items[itemIndex] = item; 
    130                                 _itemMediaSequences[itemIndex] = _lastMediaSequence; 
     130                                _itemMediaSequences[_lastMediaSequence] = itemIndex; 
    131131                                _itemKeyUris[itemIndex] = _pLastKeyUri; 
    132132                                _itemUris[itemIndex] = pLine; 
     
    189189} 
    190190 
    191 string Playlist::GetItemUri(uint32_t index) { 
     191string Playlist::GetItemUri(uint32_t &sequence) { 
     192        uint32_t index = GetIndex(sequence); 
    192193        if (index >= _itemUris.size()) 
    193194                return ""; 
     
    203204} 
    204205 
    205 string Playlist::GetItemKeyUri(uint32_t index) { 
     206string Playlist::GetItemKeyUri(uint32_t &sequence) { 
     207        uint32_t index = GetIndex(sequence); 
    206208        if (index >= _itemKeyUris.size()) 
    207209                return ""; 
     
    211213} 
    212214 
    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) { 
     215uint32_t Playlist::GetItemBandwidth(uint32_t &sequence) { 
     216        uint32_t index = GetIndex(sequence); 
    220217        if (index >= _itemBandwidths.size()) 
    221218                return 0; 
     
    223220} 
    224221 
    225 Variant Playlist::GetItemVariant(uint32_t index) { 
    226         if (index >= _items.size()) 
    227                 return Variant(); 
     222Variant Playlist::GetItemVariant(uint32_t &sequence) { 
     223        uint32_t index = GetIndex(sequence); 
    228224        Variant result; 
    229225        result["encryptionKeyUri"] = GetItemKeyUri(index); 
     
    233229} 
    234230 
    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 } 
     231uint32_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.