Class: QTRefMovie::QTDataRate

Inherits:
QTBase
  • Object
show all
Defined in:
lib/qtrefmovie.rb

Overview

Data Rate Atom A data rate atom specifies the minimum data rate required to play a movie. This is normally compared to the connection speed setting in the user’s QuickTime Settings control panel. Applications should play the movie with the highest data rate less than or equal to the user’s connection speed. If the connection speed is slower than any movie’s data rate, applications should play the movie with the lowest data rate. The movie with the highest data rate is assumed to have the highest quality.

Only one data rate atom is allowed in a given reference movie descriptor atom.

A data rate atom may contain the following information.

Size The number of bytes in this data rate atom.

Type The type of this atom; this field must be set to ‘rmdr’.

Flags A 32-bit integer that is currently always 0.

Data rate The required data rate in bits per second, expressed as a 32-bit integer.

Instance Method Summary collapse

Methods inherited from QTBase

#add_chunk

Constructor Details

#initialize(rate = nil) ⇒ QTDataRate

Returns a new instance of QTDataRate.



355
356
357
358
359
360
361
# File 'lib/qtrefmovie.rb', line 355

def initialize( rate = nil )
  super()
  @type = 'rmdr'
  @flag = 0
  @rate = 256000
  set_rate(rate) unless rate.nil?
end

Instance Method Details

#ratesObject



363
364
365
366
367
368
369
370
371
372
373
374
375
# File 'lib/qtrefmovie.rb', line 363

def rates
  { '28.8 modem'  => 28800,
    '56k modem'   => 56000,
    'isdn'        => 64000,
    'dual isdn'   => 128000,
    '256 kbps'    => 256000,
    '384 kbps'    => 384000,
    '512 kbps'    => 512000,
    '768 kbps'    => 768000,
    '1 mbps'      => 1000000,
    't1'          => 1500000,
    'intranet'    => 2147483647 }
end

#set_rate(rate) ⇒ Object



377
378
379
# File 'lib/qtrefmovie.rb', line 377

def set_rate( rate )
  @rate = rates[rate] || rate
end

#sizeObject



381
382
383
# File 'lib/qtrefmovie.rb', line 381

def size
  4 * 4
end

#to_sObject



385
386
387
388
389
390
# File 'lib/qtrefmovie.rb', line 385

def to_s
  str =  [size].pack('N')
  str += @type
  str += [@flag].pack('N')
  str += [@rate].pack('N')
end