Changeset 7106

Show
Ignore:
Timestamp:
01/25/10 21:50:04 (7 months ago)
Author:
metamorph68
Message:

Added back internal AAC+ encoding..

Location:
trunk/liquidsoap/src
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/liquidsoap/src/Makefile

    r7072 r7106  
    102102        encoder/external_encoder.ml \ 
    103103        $(if $(W_LAME),encoder/lame_encoder.ml) \ 
    104         # $(if $(W_AACPLUS),outputs/aacplus_encoded.ml) \ 
    105         $(if $(W_FAAC),outputs/faac_encoded.ml) 
     104        $(if $(W_AACPLUS),encoder/aacplus_encoder.ml) \ 
     105        # $(if $(W_FAAC),outputs/faac_encoded.ml) 
    106106 
    107107outputs = outputs/output.ml $(if $(W_AO),outputs/ao_out.ml) \ 
  • trunk/liquidsoap/src/encoder/encoder.ml

    r7067 r7106  
    7878      (string_of_stereo m.stereo) 
    7979      m.quality 
     80      m.samplerate 
     81      m.bitrate 
     82 
     83end 
     84 
     85module AACPlus = 
     86struct 
     87 
     88  type t = { 
     89    channels   : int ; 
     90    samplerate : int ; 
     91    bitrate    : int ; 
     92  } 
     93 
     94  let to_string m = 
     95    Printf.sprintf "%%aac+(channels=%d,samplerate=%d,bitrate=%d)" 
     96      m.channels 
    8097      m.samplerate 
    8198      m.bitrate 
     
    239256  | Ogg of Ogg.t 
    240257  | MP3 of MP3.t 
     258  | AACPlus of AACPlus.t 
    241259  | External of External.t 
    242260 
     
    247265  | MP3 m -> 
    248266      { Frame.audio = if m.MP3.stereo then 2 else 1 ; 
     267        Frame.video = 0 ; Frame.midi = 0 } 
     268  | AACPlus m -> 
     269      { Frame.audio = m.AACPlus.channels ; 
    249270        Frame.video = 0 ; Frame.midi = 0 } 
    250271  | Ogg l -> 
     
    276297  | Ogg w -> Ogg.to_string w 
    277298  | MP3 w -> MP3.to_string w 
     299  | AACPlus w -> AACPlus.to_string w 
    278300  | External w -> External.to_string w 
    279301 
  • trunk/liquidsoap/src/lang/lang_lexer.mll

    r7066 r7106  
    138138  | "%wav" { WAV } 
    139139  | "%mp3" { MP3 } 
     140  | "%aac+" { AACPLUS } 
     141  | "%aacplus" { AACPLUS } 
    140142 
    141143  | '[' { LBRA } 
  • trunk/liquidsoap/src/lang/lang_parser.mly

    r7067 r7106  
    145145    in 
    146146      mk (Encoder (Encoder.MP3 mp3)) 
     147 
     148  let mk_aacplus params = 
     149    let defaults = 
     150      { Encoder.AACPlus. 
     151          channels = 2 ; 
     152          samplerate = 44100 ; 
     153          bitrate = 64 } 
     154    in 
     155    let aacplus = 
     156      List.fold_left 
     157        (fun f -> 
     158          function 
     159            | ("channels",{ term = Int i }) -> 
     160                { f with Encoder.AACPlus.channels = i } 
     161            | ("samplerate",{ term = Int i }) -> 
     162                { f with Encoder.AACPlus.samplerate = i } 
     163            | ("bitrate",{ term = Int i }) -> 
     164                { f with Encoder.AACPlus.bitrate = i } 
     165            | ("",{ term = Var s }) when String.lowercase s = "mono" -> 
     166                { f with Encoder.AACPlus.channels = 1 } 
     167            | ("",{ term = Var s }) when String.lowercase s = "stereo" -> 
     168                { f with Encoder.AACPlus.channels = 2 } 
     169 
     170            | _ -> raise Parsing.Parse_error) 
     171        defaults params 
     172    in 
     173      mk (Encoder (Encoder.AACPlus aacplus)) 
    147174 
    148175  let mk_external params = 
     
    390417%token <int option list> TIME 
    391418%token <int option list * int option list> INTERVAL 
    392 %token OGG VORBIS VORBIS_CBR VORBIS_ABR THEORA DIRAC SPEEX WAV MP3 EXTERNAL 
     419%token OGG VORBIS VORBIS_CBR VORBIS_ABR THEORA DIRAC SPEEX WAV AACPLUS MP3 EXTERNAL 
    393420%token EOF 
    394421%token BEGIN END GETS TILD 
     
    457484  | GET expr                         { mk (Get $2) } 
    458485  | MP3 app_opt                      { mk_mp3 $2 } 
     486  | AACPLUS app_opt                      { mk_aacplus $2 } 
    459487  | EXTERNAL app_opt                 { mk_external $2 } 
    460488  | WAV app_opt                      { mk_wav $2 } 
     
    509537  | cexpr SET expr                   { mk (Set ($1,$3)) } 
    510538  | MP3 app_opt                      { mk_mp3 $2 } 
     539  | AACPLUS app_opt                      { mk_aacplus $2 } 
    511540  | EXTERNAL app_opt                 { mk_external $2 } 
    512541  | WAV app_opt                      { mk_wav $2 } 
  • trunk/liquidsoap/src/outputs/icecast2.ml

    r7066 r7106  
    8989 
    9090  let source = Lang.assoc "" 2 p in 
    91   let encoder_factory,ogg,icecast_info = 
     91  let encoder_factory,format,icecast_info = 
    9292    let v = Lang.assoc "" 1 p in 
    9393    let enc = Lang.to_format v in 
    94     let icecast_info,ogg = 
     94    let icecast_info,format = 
    9595      match enc with 
    9696        | Encoder.MP3 m -> 
     
    9999              samplerate = Some m.Encoder.MP3.samplerate ; 
    100100              channels = Some (if m.Encoder.MP3.stereo then 2 else 1) 
    101             }, false 
     101            }, Some Cry.mpeg 
     102        | Encoder.AACPlus m -> 
     103            { quality = None ; 
     104              bitrate = Some m.Encoder.AACPlus.bitrate ; 
     105              samplerate = Some m.Encoder.AACPlus.samplerate ; 
     106              channels = Some m.Encoder.AACPlus.channels 
     107            }, Some (Cry.content_type_of_string "audio/aacp") 
    102108        | Encoder.External m -> 
    103109            { quality = None ; 
     
    105111              samplerate = Some m.Encoder.External.samplerate ; 
    106112              channels = Some m.Encoder.External.channels 
    107             }, false 
     113            }, None 
    108114        | Encoder.Ogg o -> 
    109115            let info = 
     
    118124                      samplerate = Some s ; 
    119125                      channels = Some n } 
     126                 
    120127                | [Encoder.Ogg.Vorbis 
    121128                     {Encoder.Vorbis.channels=n; 
     
    138145              raise (Lang.Invalid_value 
    139146                       (v, "icy protocol (shoutcast) does not support Ogg")) ; 
    140               info, true 
     147              info, Some Cry.ogg_application 
    141148        | Encoder.WAV _ -> 
    142149            raise (Lang.Invalid_value (v, "WAV is not supported")) 
     
    148155                     (v, "No encoder found for that format")) 
    149156    in 
    150       encoder_factory, ogg, icecast_info 
     157      encoder_factory, format, icecast_info 
    151158  in 
    152159 
     
    154161    let f = s "format" in 
    155162      if f <> "" then Cry.content_type_of_string f else 
    156         if ogg then Cry.ogg_application else Cry.mpeg 
     163        match format with  
     164          | Some x -> x 
     165          | None   -> raise (Lang.Invalid_value (Lang.assoc "" 1 p,  
     166                                                 "No content-type (mime) found, \ 
     167                                                  please specify one.")) 
     168  in 
     169 
     170  let ogg =  
     171   (Cry.string_of_content_type format = Cry.string_of_content_type Cry.ogg_application) || 
     172   (Cry.string_of_content_type format = Cry.string_of_content_type Cry.ogg_audio) || 
     173   (Cry.string_of_content_type format = Cry.string_of_content_type Cry.ogg_video) 
    157174  in 
    158175