mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
spice-html5 updated.
This commit is contained in:
parent
12c80c5021
commit
b05a252d7c
36 changed files with 1356 additions and 1415 deletions
static/js/spice-html5
110
static/js/spice-html5/webm.js
Normal file → Executable file
110
static/js/spice-html5/webm.js
Normal file → Executable file
|
@ -61,6 +61,10 @@ var WEBM_CODEC_DELAY = [ 0x56, 0xAA ];
|
|||
var WEBM_CODEC_PRIVATE = [ 0x63, 0xA2 ];
|
||||
var WEBM_CODEC_ID = [ 0x86 ];
|
||||
|
||||
var WEBM_VIDEO = [ 0xE0 ] ;
|
||||
var WEBM_PIXEL_WIDTH = [ 0xB0 ] ;
|
||||
var WEBM_PIXEL_HEIGHT = [ 0xBA ] ;
|
||||
|
||||
var WEBM_AUDIO = [ 0xE1 ] ;
|
||||
var WEBM_SAMPLING_FREQUENCY = [ 0xB5 ] ;
|
||||
var WEBM_CHANNELS = [ 0x9F ] ;
|
||||
|
@ -80,8 +84,11 @@ var OPUS_CHANNELS = 2;
|
|||
var SPICE_PLAYBACK_CODEC = 'audio/webm; codecs="opus"';
|
||||
var MAX_CLUSTER_TIME = 1000;
|
||||
|
||||
var EXPECTED_PACKET_DURATION = 10;
|
||||
var GAP_DETECTION_THRESHOLD = 50;
|
||||
|
||||
var SPICE_VP8_CODEC = 'video/webm; codecs="vp8"';
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
** EBML utility functions
|
||||
** These classes can create the binary representation of a webm file
|
||||
|
@ -291,6 +298,34 @@ webm_Audio.prototype =
|
|||
},
|
||||
}
|
||||
|
||||
function webm_Video(width, height)
|
||||
{
|
||||
this.id = WEBM_VIDEO;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
webm_Video.prototype =
|
||||
{
|
||||
to_buffer: function(a, at)
|
||||
{
|
||||
at = at || 0;
|
||||
var dv = new DataView(a);
|
||||
at = EBML_write_array(this.id, dv, at);
|
||||
at = EBML_write_u64_data_len(this.buffer_size() - 8 - this.id.length, dv, at);
|
||||
at = EBML_write_u16_value(WEBM_PIXEL_WIDTH, this.width, dv, at)
|
||||
at = EBML_write_u16_value(WEBM_PIXEL_HEIGHT, this.height, dv, at)
|
||||
return at;
|
||||
},
|
||||
buffer_size: function()
|
||||
{
|
||||
return this.id.length + 8 +
|
||||
WEBM_PIXEL_WIDTH.length + 1 + 2 +
|
||||
WEBM_PIXEL_HEIGHT.length + 1 + 2;
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ---------------------------
|
||||
SeekHead not currently used. Hopefully not needed.
|
||||
|
@ -356,7 +391,7 @@ webm_SeekHead.prototype =
|
|||
End of Seek Head
|
||||
*/
|
||||
|
||||
function webm_TrackEntry()
|
||||
function webm_AudioTrackEntry()
|
||||
{
|
||||
this.id = WEBM_TRACK_ENTRY;
|
||||
this.number = 1;
|
||||
|
@ -385,7 +420,7 @@ function webm_TrackEntry()
|
|||
];
|
||||
}
|
||||
|
||||
webm_TrackEntry.prototype =
|
||||
webm_AudioTrackEntry.prototype =
|
||||
{
|
||||
to_buffer: function(a, at)
|
||||
{
|
||||
|
@ -431,6 +466,70 @@ webm_TrackEntry.prototype =
|
|||
this.audio.buffer_size();
|
||||
},
|
||||
}
|
||||
|
||||
function webm_VideoTrackEntry(width, height)
|
||||
{
|
||||
this.id = WEBM_TRACK_ENTRY;
|
||||
this.number = 1;
|
||||
this.uid = 1;
|
||||
this.type = 1; // Video
|
||||
this.flag_enabled = 1;
|
||||
this.flag_default = 1;
|
||||
this.flag_forced = 1;
|
||||
this.flag_lacing = 0;
|
||||
this.min_cache = 0; // fixme - check
|
||||
this.max_block_addition_id = 0;
|
||||
this.codec_decode_all = 0; // fixme - check
|
||||
this.seek_pre_roll = 0; // 80000000; // fixme - check
|
||||
this.codec_delay = 80000000; // Must match codec_private.preskip
|
||||
this.codec_id = "V_VP8";
|
||||
this.video = new webm_Video(width, height);
|
||||
}
|
||||
|
||||
webm_VideoTrackEntry.prototype =
|
||||
{
|
||||
to_buffer: function(a, at)
|
||||
{
|
||||
at = at || 0;
|
||||
var dv = new DataView(a);
|
||||
at = EBML_write_array(this.id, dv, at);
|
||||
at = EBML_write_u64_data_len(this.buffer_size() - 8 - this.id.length, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_TRACK_NUMBER, this.number, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_TRACK_UID, this.uid, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_FLAG_ENABLED, this.flag_enabled, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_FLAG_DEFAULT, this.flag_default, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_FLAG_FORCED, this.flag_forced, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_FLAG_LACING, this.flag_lacing, dv, at);
|
||||
at = EBML_write_data(WEBM_CODEC_ID, this.codec_id, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_MIN_CACHE, this.min_cache, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_MAX_BLOCK_ADDITION_ID, this.max_block_addition_id, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_CODEC_DECODE_ALL, this.codec_decode_all, dv, at);
|
||||
at = EBML_write_u32_value(WEBM_CODEC_DELAY, this.codec_delay, dv, at);
|
||||
at = EBML_write_u32_value(WEBM_SEEK_PRE_ROLL, this.seek_pre_roll, dv, at);
|
||||
at = EBML_write_u8_value(WEBM_TRACK_TYPE, this.type, dv, at);
|
||||
at = this.video.to_buffer(a, at);
|
||||
return at;
|
||||
},
|
||||
buffer_size: function()
|
||||
{
|
||||
return this.id.length + 8 +
|
||||
WEBM_TRACK_NUMBER.length + 1 + 1 +
|
||||
WEBM_TRACK_UID.length + 1 + 1 +
|
||||
WEBM_FLAG_ENABLED.length + 1 + 1 +
|
||||
WEBM_FLAG_DEFAULT.length + 1 + 1 +
|
||||
WEBM_FLAG_FORCED.length + 1 + 1 +
|
||||
WEBM_FLAG_LACING.length + 1 + 1 +
|
||||
WEBM_CODEC_ID.length + this.codec_id.length + 1 +
|
||||
WEBM_MIN_CACHE.length + 1 + 1 +
|
||||
WEBM_MAX_BLOCK_ADDITION_ID.length + 1 + 1 +
|
||||
WEBM_CODEC_DECODE_ALL.length + 1 + 1 +
|
||||
WEBM_CODEC_DELAY.length + 1 + 4 +
|
||||
WEBM_SEEK_PRE_ROLL.length + 1 + 4 +
|
||||
WEBM_TRACK_TYPE.length + 1 + 1 +
|
||||
this.video.buffer_size();
|
||||
},
|
||||
}
|
||||
|
||||
function webm_Tracks(entry)
|
||||
{
|
||||
this.id = WEBM_TRACKS;
|
||||
|
@ -526,9 +625,6 @@ function webm_Header()
|
|||
this.info = new webm_SegmentInformation;
|
||||
|
||||
this.seek_head.track.pos = this.seek_head.info.pos + this.info.buffer_size();
|
||||
|
||||
this.track_entry = new webm_TrackEntry;
|
||||
this.tracks = new webm_Tracks(this.track_entry);
|
||||
}
|
||||
|
||||
webm_Header.prototype =
|
||||
|
@ -539,7 +635,6 @@ webm_Header.prototype =
|
|||
at = this.ebml.to_buffer(a, at);
|
||||
at = this.segment.to_buffer(a, at);
|
||||
at = this.info.to_buffer(a, at);
|
||||
at = this.tracks.to_buffer(a, at);
|
||||
|
||||
return at;
|
||||
},
|
||||
|
@ -547,7 +642,6 @@ webm_Header.prototype =
|
|||
{
|
||||
return this.ebml.buffer_size() +
|
||||
this.segment.buffer_size() +
|
||||
this.info.buffer_size() +
|
||||
this.tracks.buffer_size();
|
||||
this.info.buffer_size();
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue