Changeset 3189

Show
Ignore:
Timestamp:
2007-08-14 00:40:27 (1 year ago)
Author:
shans
Message:

Correct packet continuation handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oogg/trunk/packet.ml

    r3188 r3189  
    11open Types 
    22 
    3 let new_packet page data isLast = 
     3let new_packet oc page data isLast = 
    44  { 
    5     p_data = data
     5    p_data = (match oc with None -> data | Some d -> d ^ data)
    66    p_granulepos = if isLast then page.raw.granulepos else None ; 
    77    p_time = if isLast then page.time else None ; 
     
    99  };; 
    1010 
    11 let page_to_packets page = 
    12   let rec _ptp raw_data = match raw_data with 
    13   | h::[l] when page.raw.continued ->  
    14         [< 'new_packet page h true; 'new_packet page l false >] 
    15   | h::[] when not page.raw.continued -> [< 'new_packet page h true >] 
    16   | h::t  -> [< 'new_packet page h false; _ptp t >] 
    17   | []    -> [< >] in 
     11let page_to_packets cont page = 
     12  let rec _ptp raw_data =  
     13    let oc = !cont in  
     14    cont := None;  
     15    match raw_data with 
     16      | h::[l] when not page.raw.last_packet_complete ->  
     17          (cont := Some l; [< 'new_packet oc page h true >]) 
     18      | [h] when not page.raw.last_packet_complete -> 
     19          ((match oc with  
     20            | None -> cont := Some h  
     21            | Some d -> cont := Some (h ^ d)); 
     22            [< >] 
     23          ) 
     24      | h::[] when page.raw.last_packet_complete ->  
     25          [< 'new_packet oc page h true >] 
     26      | h::t  -> [< 'new_packet oc page h false; _ptp t >] 
     27      | []    -> [< >] in 
    1828  _ptp page.raw.raw_data;; 
    1929 
    20 let rec to_packetStream pstream = match pstream with parser 
    21   | [< 'page ; rest >] -> [< page_to_packets page ; to_packetStream rest >] 
    22   | [< >] -> [< >];; 
     30let to_packetStream pstream = 
     31  let cont = ref None in 
     32  let rec _tps pstream = match pstream with parser 
     33    | [< 'page ; rest >] -> [< page_to_packets cont page ; _tps rest >] 
     34    | [< >] -> [< >] in  
     35  _tps pstream;; 
    2336 
    2437type reconstruct_context = {