winlin

refine the srs js player and publisher, add private object

@@ -427,8 +427,10 @@ function srs_publiser_get_codec( @@ -427,8 +427,10 @@ function srs_publiser_get_codec(
427 * @param container the html container id. 427 * @param container the html container id.
428 * @param width a float value specifies the width of player. 428 * @param width a float value specifies the width of player.
429 * @param height a float value specifies the height of player. 429 * @param height a float value specifies the height of player.
  430 +* @param private_object [optional] an object that used as private object,
  431 +* for example, the logic chat object which owner this player.
430 */ 432 */
431 -function SrsPlayer(container, width, height) { 433 +function SrsPlayer(container, width, height, private_object) {
432 if (!SrsPlayer.__id) { 434 if (!SrsPlayer.__id) {
433 SrsPlayer.__id = 100; 435 SrsPlayer.__id = 100;
434 } 436 }
@@ -438,6 +440,7 @@ function SrsPlayer(container, width, height) { @@ -438,6 +440,7 @@ function SrsPlayer(container, width, height) {
438 440
439 SrsPlayer.__players.push(this); 441 SrsPlayer.__players.push(this);
440 442
  443 + this.private_object = private_object;
441 this.container = container; 444 this.container = container;
442 this.width = width; 445 this.width = width;
443 this.height = height; 446 this.height = height;
@@ -611,8 +614,10 @@ function __srs_on_player_timer(id, time, buffer_length) { @@ -611,8 +614,10 @@ function __srs_on_player_timer(id, time, buffer_length) {
611 * @param container the html container id. 614 * @param container the html container id.
612 * @param width a float value specifies the width of publisher. 615 * @param width a float value specifies the width of publisher.
613 * @param height a float value specifies the height of publisher. 616 * @param height a float value specifies the height of publisher.
  617 +* @param private_object [optional] an object that used as private object,
  618 +* for example, the logic chat object which owner this publisher.
614 */ 619 */
615 -function SrsPublisher(container, width, height) { 620 +function SrsPublisher(container, width, height, private_object) {
616 if (!SrsPublisher.__id) { 621 if (!SrsPublisher.__id) {
617 SrsPublisher.__id = 100; 622 SrsPublisher.__id = 100;
618 } 623 }
@@ -622,6 +627,7 @@ function SrsPublisher(container, width, height) { @@ -622,6 +627,7 @@ function SrsPublisher(container, width, height) {
622 627
623 SrsPublisher.__publishers.push(this); 628 SrsPublisher.__publishers.push(this);
624 629
  630 + this.private_object = private_object;
625 this.container = container; 631 this.container = container;
626 this.width = width; 632 this.width = width;
627 this.height = height; 633 this.height = height;
@@ -184,7 +184,9 @@ @@ -184,7 +184,9 @@
184 // if previous exists, ignore, only add new here. 184 // if previous exists, ignore, only add new here.
185 var previous_chat = get_previous_chat_user(previous_chats, chat.id); 185 var previous_chat = get_previous_chat_user(previous_chats, chat.id);
186 if (previous_chat) { 186 if (previous_chat) {
  187 + // update reference.
187 chat.player = previous_chat.player; 188 chat.player = previous_chat.player;
  189 + chat.player.private_object = chat;
188 continue; 190 continue;
189 } 191 }
190 192
@@ -209,7 +211,7 @@ @@ -209,7 +211,7 @@
209 211
210 if (!no_play) { 212 if (!no_play) {
211 // start the realtime player. 213 // start the realtime player.
212 - var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300); 214 + var _player = new SrsPlayer("rp_raw_" + chat.id, 600, 300, chat);
213 _player.on_player_ready = function() { 215 _player.on_player_ready = function() {
214 this.set_bt(0.5); 216 this.set_bt(0.5);
215 this.set_fs("screen", 100); 217 this.set_fs("screen", 100);