Skip to content

Commit

Permalink
標準出力のデータを読み込んで放送させることに成功。
Browse files Browse the repository at this point in the history
やったね。
  • Loading branch information
taktod committed Nov 23, 2012
1 parent a429295 commit abdb2f8
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 18 deletions.
1 change: 1 addition & 0 deletions client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -Xmx512m -cp conf:lib/*:stdinFlazr.jar com.ttProject.flazr.RtmpClient $*
Binary file added lib/commons-cli-1.2.jar
Binary file not shown.
Binary file added lib/commons-codec-1.2.jar
Binary file not shown.
Binary file added lib/commons-httpclient-3.1.jar
Binary file not shown.
Binary file added lib/flazr2.jar
Binary file not shown.
Binary file added lib/jcl104-over-slf4j-1.4.2.jar
Binary file not shown.
Binary file added lib/log4j-1.2.14.jar
Binary file not shown.
Binary file added lib/netty-3.1.5.GA.jar
Binary file not shown.
Binary file added lib/slf4j-api-1.4.2.jar
Binary file not shown.
Binary file added lib/slf4j-log4j12-1.4.2.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ stdinFlazr
・とりあえず実行母体をつくりました。
10:27
・変更の必要なファイルを抽出して、動作を上書きできるように改良した。
15:45
・とりあえずcatでflvを開いてpipeでつないだ動作でうまく動作させることができた。
$ cat music.flv | ./client.sh -host 49.212.39.17 -app live -live test -

あと、心配なことは、リアルタイム動作させてて、flvデータが枯渇したらどうなるか・・・ですね。
手持ちにいいソースがないので、とりあえず放置しておきますが・・・
このあたりきちっとしようとしたら、やっぱりrtmpPublisherの動作に口出しして、現在時刻もうまくトレースする必要があると思う。
13 changes: 0 additions & 13 deletions src/com/ttProject/flazr/FlvPacketReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ public class FlvPacketReader {
private ByteBuffer buffer = null;
public List<FlvAtom> getPackets(ByteBuffer data) {
if(buffer != null) {
int position = buffer.position();
byte[] dat = new byte[11];
buffer.get(dat);
System.out.println(Utils.toHex(dat, true));
buffer.position(position);
System.out.println(buffer.remaining());
System.out.println(data.remaining());
int length = buffer.remaining() + data.remaining();
ByteBuffer newBuffer = ByteBuffer.allocate(length);
newBuffer.put(buffer);
Expand Down Expand Up @@ -54,7 +47,6 @@ public List<FlvAtom> getPackets(ByteBuffer data) {
*/
private FlvAtom analizeData(ByteBuffer buffer) {
if(!firstChecked) {
System.out.println("check again");
if(buffer.remaining() < 13) {
// データがたりないので、次のデータ待ち
return null;
Expand Down Expand Up @@ -95,11 +87,6 @@ private FlvAtom analizeData(ByteBuffer buffer) {
int size = getSizeFromHeader(packetHeader);
System.out.println(11+ size + 4);
if(buffer.remaining() < size + 4) {
// 読み込むのにはデータがたりなかった。
buffer.position(position);
byte[] dat = new byte[11];
buffer.get(dat);
System.out.println(Utils.toHex(dat, true));
buffer.position(position);
return null;
}
Expand Down
10 changes: 5 additions & 5 deletions src/com/ttProject/flazr/io/flv/FlvLiveReader.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ttProject.flazr.io.flv;

import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;

Expand Down Expand Up @@ -34,10 +34,10 @@ public FlvLiveReader(final String path) {
public void run() {
try {
FlvPacketReader reader = new FlvPacketReader();
// ReadableByteChannel stdinChannel = Channels.newChannel(System.in);
ReadableByteChannel stdinChannel = Channels.newChannel(System.in);
// dummy
String targetFile = System.getProperty("user.home") + "/Sites/mario/mario.flv";
FileChannel stdinChannel = new FileInputStream(targetFile).getChannel();
// String targetFile = System.getProperty("user.home") + "/Sites/mario/mario.flv";
// FileChannel stdinChannel = new FileInputStream(targetFile).getChannel();
// 実処理
// データを確認する。
while(true) {
Expand Down
Binary file added stdinFlazr.jar
Binary file not shown.

0 comments on commit abdb2f8

Please sign in to comment.