...
To analyze the code get stream-diagnostic.js file version with hash c306c1bbf49bfcbd8e24be927ae95f63b7dbaaba hash 66cc393 that can be found here and and is avalable to download in build 0.5.28.2753.2747133.
1. API initializing.
Flashphoner.init() code
Code Block | ||||
---|---|---|---|---|
| ||||
Flashphoner.init({ flashMediaProviderSwfLocation: '../../../../media-provider.swf', createMicGainNode: false }); |
2. Connection to the server
Flashphoner.createSession() code
Every action will be printed to the special page element by function log() call
...
ConnectionStatusEvent ESTABLISHED code
Code Block | ||||
---|---|---|---|---|
| ||||
session = Flashphoner.createSession({urlServer: url}).on(SESSION_STATUS.ESTABLISHED, function(session){ //session connected, start streaming startStreaming(session); }).on(SESSION_STATUS.DISCONNECTED, function(){ ... }).on(SESSION_STATUS.FAILED, function(){ ... }).on(SESSION_STATUS.DEBUG, function(event){ ... }); |
...
session.startDebug(), session.createStream(), publish() code
On stream creation these parameters are passed:
...
StreamStatusEvent PUBLISHING code
On this event, preview stream is created with createStream(), and play() called to play it
Code Block | ||||
---|---|---|---|---|
| ||||
session.createStream({ name: streamName, display: localVideo, cacheLocalResources: true, receiveVideo: false, receiveAudio: false... }).on(STREAM_STATUS.PUBLISHING, function(publishStream){ log("Stream " + streamName + " " + STREAM_STATUS.PUBLISHING); setStatus(STREAM_STATUS.PUBLISHING); //play preview session.createStream({ name: streamName, display: remoteVideo ... }).play(); }).on(STREAM_STATUS.UNPUBLISHED, function(){ ... }).on(STREAM_STATUS.FAILED, function(stream){ ... }).publish(); |
6. PreviewsStream playback stop
previewStream.stop() code
Code Block | ||||
---|---|---|---|---|
| ||||
function onStarted(publishStream, previewStream) { $("#publishBtn").text("Stop").off('click').click(function(){ $(this).prop('disabled', true); previewStream.stop(); }).prop('disabled', false); $("#downloadDiv").hide(); } |
...
StreamStatusEvent STOPPED code
Code Block | ||||
---|---|---|---|---|
| ||||
session.createStream({ name: streamName, display: remoteVideo }).on(STREAM_STATUS.PLAYING, function(previewStream){ ... }).on(STREAM_STATUS.STOPPED, function(){ log("Stream " + streamName + " " + STREAM_STATUS.STOPPED); publishStream.stop(); }).on(STREAM_STATUS.FAILED, function(stream){ ... }).play(); |
8. Streaming stop when playback is stopped
publishStream.stop() code
Code Block | ||||
---|---|---|---|---|
| ||||
session.createStream({ name: streamName, display: remoteVideo }).on(STREAM_STATUS.PLAYING, function(previewStream){ ... }).on(STREAM_STATUS.STOPPED, function(){ log("Stream " + streamName + " " + STREAM_STATUS.STOPPED); publishStream.stop(); }).on(STREAM_STATUS.FAILED, function(stream){ ... }).play(); |
...
StreamStatusEvent UNPUBLISHED code
Code Block | ||||
---|---|---|---|---|
| ||||
session.createStream({ name: streamName, display: localVideo, cacheLocalResources: true, receiveVideo: false, receiveAudio: false }).on(STREAM_STATUS.PUBLISHING, function(publishStream){ ... }).on(STREAM_STATUS.UNPUBLISHED, function(){ setStatus(STREAM_STATUS.UNPUBLISHED); log("Stream " + streamName + " " + STREAM_STATUS.UNPUBLISHED); //enable start button onStopped(); }).on(STREAM_STATUS.FAILED, function(stream){ ... }).publish(); |
10. Debug information output stop when streaming is stopped
session.stopDebug() code
Code Block | ||||
---|---|---|---|---|
| ||||
function onStopped() { ... if (session) session.stopDebug(); } |
...
ConnectionStatusEvent DEBUG code
On this event, the link to download session log is forming
...
12. Debug information output to the page element
Code Block | ||||
---|---|---|---|---|
| ||||
function log(string) { document.getElementById("debug").innerHTML += string + '</br>'; } |