Changeset 7166

Show
Ignore:
Timestamp:
02/12/10 19:09:24 (7 months ago)
Author:
dbaelde
Message:

Allow for media requests with kind (0,0,0), by flagging explicitly raw
requests as such. The "dummy" kind (0,0,0) is still used at the Lang level.
I didn't force the distinction using phantom types as before, it didn't
seem too important -- I hope I'm not missing anything important here.

Location:
trunk/liquidsoap/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/liquidsoap/src/lang/lang.ml

    r7086 r7166  
    216216 
    217217let request r = 
    218   mk (request_t (kind_type_of_frame_kind (Request.kind r))) (Request r) 
     218  let kind = 
     219    match Request.kind r with 
     220      | Some k -> k 
     221      | None -> let z = Frame.Zero in {Frame.audio=z;video=z;midi=z} 
     222  in 
     223    mk (request_t (kind_type_of_frame_kind kind)) (Request r) 
    219224 
    220225let val_fun p ~ret_t f = 
  • trunk/liquidsoap/src/request.ml

    r7110 r7166  
    187187type status = Idle | Resolving | Ready | Playing | Destroyed 
    188188 
    189 (** Each request has a kind, telling how it might be used. 
    190   * Non-trivial kinds are for "media requests", audio or video files. 
    191   * For other, "raw requests", we use the following empty kind. *) 
    192 let raw_kind = 
    193   { Frame. 
    194       audio = Frame.Zero ; 
    195       video = Frame.Zero ; 
    196       midi  = Frame.Zero } 
    197  
    198189type t = { 
    199190  id : int ; 
    200191  initial_uri : string ; 
    201   kind : Frame.content_kind ; 
     192  kind : Frame.content_kind option ; (* No kind for raw requests *) 
    202193  persistent : bool ; 
    203194 
     
    338329    | No_indicator -> () 
    339330  in 
    340     if t.kind <> raw_kind then check_decodable t.kind 
     331    match t.kind with None -> () | Some k -> check_decodable k 
    341332 
    342333let push_indicators t l = 
     
    356347  t.indicators <> [] && 
    357348  Sys.file_exists (peek_indicator t).string && 
    358   ( t.decoder <> None || t.kind = raw_kind ) 
     349  ( t.decoder <> None || t.kind = None ) 
    359350 
    360351(** [get_filename request] returns 
     
    414405      | None -> () 
    415406    end ; 
    416     if t.kind <> raw_kind then 
    417       replace "kind" (Frame.string_of_content_kind t.kind) ; 
     407    begin match t.kind with 
     408      | None -> () 
     409      | Some k -> 
     410          replace "kind" (Frame.string_of_content_kind k) 
     411    end ; 
    418412    replace "status" 
    419413      (match t.status with 
     
    486480    t 
    487481 
    488 let create_raw = create ~kind:raw_kind 
     482let create_raw = create ~kind:None 
     483let create ~kind = create ~kind:(Some kind) 
    489484 
    490485let on_air t = 
  • trunk/liquidsoap/src/request.mli

    r7110 r7166  
    5252  t 
    5353 
    54 val kind : t -> Frame.content_kind 
     54(** Return the kind of a media request, None for raw requests. *) 
     55val kind : t -> Frame.content_kind option 
    5556 
    5657(** Destroying of a requests causes its file to be deleted if it's a temporary 
  • trunk/liquidsoap/src/sources/request_source.ml

    r7120 r7166  
    7676          false 
    7777      | Some req when Request.is_ready req -> 
    78           assert (Frame.kind_sub_kind (Request.kind req) kind) ; 
     78          assert (Frame.kind_sub_kind 
     79                    (Utils.get_some (Request.kind req)) 
     80                    kind) ; 
    7981          (* [Request.is_ready] ensures that we can get a filename from 
    8082           * the request, and it can be decoded. *)