Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2013-12-25 17:26:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
70dc3dbb53809daa1015e3ed01b08a83c2df7430
70dc3dbb
1 parent
3ab867d9
layout the chat in 2x8 table
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
121 行增加
和
43 行删除
trunk/research/players/js/srs.page.js
trunk/research/players/js/srs.publisher.js
trunk/research/players/srs_chat.html
trunk/research/players/js/srs.page.js
100644 → 100755
查看文件 @
70dc3db
...
...
@@ -286,19 +286,19 @@ function srs_chat_initialize_page(
//var gops = ["0.3", "0.5", "1", "2", "3", "4",
// "5", "6", "7", "8", "9", "10", "15", "20"];
$
(
sl_gop
+
" option[value='
0.5
']"
).
attr
(
"selected"
,
true
);
$
(
sl_gop
+
" option[value='
1
']"
).
attr
(
"selected"
,
true
);
//var sizes = ["176x144", "320x240", "352x240",
// "352x288", "460x240", "640x480", "720x480", "720x576", "800x600",
// "1024x768", "1280x720", "1360x768", "1920x1080"];
$
(
sl_size
+
" option[value='
320x24
0']"
).
attr
(
"selected"
,
true
);
$
(
sl_size
+
" option[value='
640x48
0']"
).
attr
(
"selected"
,
true
);
//var fpses = ["5", "10", "15", "20", "24", "25", "29.97", "30"];
$
(
sl_fps
+
" option[value='1
0
']"
).
attr
(
"selected"
,
true
);
$
(
sl_fps
+
" option[value='1
5
']"
).
attr
(
"selected"
,
true
);
//var bitrates = ["50", "200", "350", "500", "650", "800",
// "950", "1000", "1200", "1500", "1800", "2000", "3000", "5000"];
$
(
sl_bitrate
+
" option[value='
20
0']"
).
attr
(
"selected"
,
true
);
$
(
sl_bitrate
+
" option[value='
35
0']"
).
attr
(
"selected"
,
true
);
}
/**
* get the vcodec and acodec.
...
...
trunk/research/players/js/srs.publisher.js
查看文件 @
70dc3db
...
...
@@ -87,6 +87,9 @@ SrsPublisher.prototype.start = function() {
* @param acodec an object contains the audio codec info.
*/
SrsPublisher
.
prototype
.
publish
=
function
(
url
,
vcodec
,
acodec
)
{
this
.
stop
();
SrsPublisher
.
__publishers
.
push
(
this
);
if
(
url
)
{
this
.
url
=
url
;
}
...
...
@@ -100,6 +103,17 @@ SrsPublisher.prototype.publish = function(url, vcodec, acodec) {
this
.
callbackObj
.
ref
.
__publish
(
this
.
url
,
this
.
width
,
this
.
height
,
this
.
vcodec
,
this
.
acodec
);
}
SrsPublisher
.
prototype
.
stop
=
function
()
{
for
(
var
i
=
0
;
i
<
SrsPublisher
.
__publishers
.
length
;
i
++
)
{
var
player
=
SrsPublisher
.
__publishers
[
i
];
if
(
player
.
id
!=
this
.
id
)
{
continue
;
}
SrsPublisher
.
__publishers
.
splice
(
i
,
1
);
break
;
}
this
.
callbackObj
.
ref
.
__stop
();
}
/**
...
...
trunk/research/players/srs_chat.html
查看文件 @
70dc3db
...
...
@@ -86,6 +86,16 @@
realtime_player
.
start
();
}
// 2x8 users
for
(
var
i
=
0
;
i
<
8
;
i
++
)
{
var
tr
=
$
(
"<tr></tr>"
).
hide
();
$
(
"#lst_chats"
).
append
(
tr
);
for
(
var
j
=
0
;
j
<
2
;
j
++
)
{
tr
.
append
(
$
(
"<td></td>"
).
attr
(
"id"
,
"td_"
+
(
i
*
8
+
j
)));
}
}
api_server
=
"http://"
+
query
.
hostname
+
":"
+
srs_get_api_server_port
()
+
"/api/v1/chats"
;
refresh
();
});
...
...
@@ -187,28 +197,84 @@
}
});
}
function
render_chat_room
(
chats
)
{
function
render_chat_room
(
original_
chats
)
{
if
(
!
self_chat
)
{
return
;
}
// new added chat
for
(
var
i
=
0
;
i
<
chats
.
length
;
i
++
)
{
var
chat
=
chats
[
i
];
var
chats
=
[];
for
(
var
i
=
0
;
i
<
original_chats
.
length
;
i
++
)
{
var
chat
=
original_chats
[
i
];
// ignore the self.
if
(
self_chat
&&
self_chat
.
id
==
chat
.
id
)
{
continue
;
}
chats
.
push
(
chat
);
}
// new added chat
for
(
var
i
=
0
;
i
<
chats
.
length
;
i
++
)
{
var
chat
=
chats
[
i
];
// if previous exists, ignore, only add new here.
var
previous_chat
=
get_previous_chat_user
(
previous_chats
,
chat
.
id
);
if
(
previous_chat
)
{
// update reference.
chat
.
ui
=
previous_chat
.
ui
;
chat
.
parent
=
previous_chat
.
parent
;
chat
.
player
=
previous_chat
.
player
;
if
(
chat
.
player
)
{
chat
.
player
.
private_object
=
chat
;
}
continue
;
}
}
// removed chat
for
(
var
i
=
0
;
i
<
previous_chats
.
length
;
i
++
)
{
var
chat
=
previous_chats
[
i
];
var
new_chat
=
get_previous_chat_user
(
chats
,
chat
.
id
);
if
(
new_chat
)
{
continue
;
}
if
(
chat
.
player
)
{
chat
.
player
.
stop
();
}
$
(
"#div_"
+
chat
.
id
).
remove
();
}
// hide empty rows.
$
(
"#lst_chats"
).
find
(
"tr"
).
each
(
function
(){
var
empty
=
true
;
$
(
this
).
find
(
"td"
).
each
(
function
(){
if
(
$
(
this
).
html
()
!=
""
)
{
empty
=
false
;
return
false
;
// abort each
}
return
true
;
});
if
(
empty
)
{
$
(
this
).
hide
();
}
});
// render the chat
for
(
var
i
=
0
;
i
<
chats
.
length
;
i
++
)
{
var
chat
=
chats
[
i
];
// if redered, ignore.
if
(
chat
.
parent
)
{
continue
;
}
// generate the ui of chat
if
(
!
chat
.
ui
)
{
global_chat_user_id
++
;
// username: a str indicates the user name.
...
...
@@ -216,6 +282,10 @@
// join_date: a str indicates the join timestamp in seconds.
// join_date_str: friendly formated time.
var
obj
=
$
(
"<div/>"
).
html
(
$
(
"#template"
).
html
());
if
(
true
)
{
// save current ui object to the chat.
chat
.
ui
=
obj
;
$
(
obj
).
attr
(
"chat_id"
,
chat
.
id
);
$
(
obj
).
attr
(
"id"
,
"div_"
+
chat
.
id
);
// for specifed chat: $("#div_" + chat_id)
$
(
obj
).
attr
(
"class"
,
"div_chat"
);
// for all chats: $(".div_chat")
...
...
@@ -225,14 +295,38 @@
$
(
obj
).
find
(
"#join_date"
).
text
(
chat
.
join_date_str
);
$
(
obj
).
find
(
"#collapseM"
).
attr
(
"id"
,
"collapse_"
+
global_chat_user_id
);
$
(
obj
).
find
(
"#headerN"
).
attr
(
"href"
,
"#collapse_"
+
global_chat_user_id
);
}
}
$
(
"#lst_chats"
).
append
(
obj
);
// find a idle td to render the chat.
var
parent
=
null
;
$
(
"#lst_chats"
).
find
(
"td"
).
each
(
function
(){
if
(
$
(
this
).
html
()
!=
""
)
{
return
true
;
}
parent
=
$
(
this
);
return
false
;
// abort each
});
if
(
!
parent
)
{
warn
(
"没有可用的位置展示流。"
);
break
;
}
$
(
parent
).
append
(
chat
.
ui
);
$
(
parent
).
parent
().
show
();
// when ui elements appent to the page,
// create the player, or flash will failed.
if
(
!
chat
.
parent
)
{
chat
.
parent
=
$
(
parent
);
if
(
!
no_play
)
{
// start the realtime player.
var
_player
=
new
SrsPlayer
(
"rp_raw_"
+
chat
.
id
,
600
,
300
,
chat
);
var
_player
=
new
SrsPlayer
(
"rp_raw_"
+
chat
.
id
,
430
,
185
,
chat
);
_player
.
on_player_ready
=
function
()
{
this
.
set_bt
(
0.5
);
this
.
play
();
};
_player
.
on_player_metadata
=
function
(
metadata
)
{
this
.
set_dar
(
0
,
0
);
...
...
@@ -262,24 +356,6 @@
chat
.
player
.
play
();
});
}
// removed chat
for
(
var
i
=
0
;
i
<
previous_chats
.
length
;
i
++
)
{
var
chat
=
previous_chats
[
i
];
// ignore the self.
if
(
self_chat
&&
self_chat
.
id
==
chat
.
id
)
{
continue
;
}
var
new_chat
=
get_previous_chat_user
(
chats
,
chat
.
id
);
if
(
new_chat
)
{
continue
;
}
if
(
chat
.
player
)
{
chat
.
player
.
stop
();
}
$
(
"#div_"
+
chat
.
id
).
remove
();
}
previous_chats
=
chats
;
...
...
@@ -325,10 +401,6 @@
// removed chat
for
(
var
i
=
0
;
i
<
previous_chats
.
length
;
i
++
)
{
var
chat
=
previous_chats
[
i
];
// ignore the self.
if
(
self_chat
&&
self_chat
.
id
==
chat
.
id
)
{
continue
;
}
if
(
chat
.
player
)
{
chat
.
player
.
stop
();
...
...
@@ -517,26 +589,18 @@
<img
src=
"img/tooltip.png"
/>
</span>
</div>
<div
id=
"collapseM"
class=
"accordion-body collapse"
>
<div
id=
"collapseM"
class=
"accordion-body collapse
in
"
>
<div
class=
"accordion-inner"
>
<div
class=
"row-fluid"
>
<div
class=
"span2"
>
</div>
<div
class=
"span8"
>
<div
id=
"chat_player"
>
<div
id=
"chat_player_raw"
>
</div>
</div>
</div>
<div
class=
"span2"
>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"container"
id=
"lst_chats"
>
</div>
<table
id=
"lst_chats"
class=
"table"
>
</table>
<div
id=
"video_modal"
class=
"modal hide fade"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
...
...
请
注册
或
登录
后发表评论