$ git clone http://tcclient.ion.nu/tc_client.git
commit 97caf4508fb59620a5ef47be6389d28a1a0818ca
Author: Alicia <...>
Date: Sun Oct 9 16:23:01 2016 +0200
Added support for sending audio packets with "/audio <length>", followed by the binary data.
diff --git a/ChangeLog b/ChangeLog
index a4b2d2c..26e0101 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Moved the backward compatibility code for avcodec_{send,receive}_{frame,packet}
Improved the RTMP acknowledgement code: counting the format 3 headers which were previously skipped, setting a more reasonable acknowledgement interval at startup and giving the server some margin before dropping outgoing video packets.
Interpret the "from_owner" subcommand "_close" to tell if our media stream was closed.
Fixed a bug that caused tc_client to not know the nickname if the chosen one wasn't available at startup, manifesting as broadcasting not working unless the initial nickname was free.
+Added support for sending audio packets with "/audio <length>", followed by the binary data.
tc_client-gtk: merged camera_remove() and camera_removebynick() into a single function, merged the deallocation of camera data into camera_free()
tc_client-gtk: moved the postprocessing code into its own source file.
tc_client-gtk: added greenscreen postprocessor.
diff --git a/README b/README
index d501438..a41b238 100644
--- a/README
+++ b/README
@@ -17,6 +17,7 @@ Commands supported by tc_client:
/forgive <nick/ID> = unban someone
/camup = open an audio/video stream for broadcasting your video
/video <length> = send a <length> bytes long encoded frame, send the frame data after this line
+/audio <length> = send a <length> bytes long encoded frame, send the frame data after this line
/camdown = close the audio/video stream
/topic <topic> = set the channel topic
/help = list these commands at runtime
diff --git a/client.c b/client.c
index 2a7c8b5..757ce42 100644
--- a/client.c
+++ b/client.c
@@ -518,6 +518,7 @@ int main(int argc, char** argv)
"/camup = open an audio/video stream for broadcasting your video\n"
"/camdown = close the broadcasting stream\n"
"/video <length> = send a <length> bytes long encoded frame, send the frame data after this line\n"
+ "/audio <length> = send a <length> bytes long encoded frame, send the frame data after this line\n"
"/topic <topic> = set the channel topic\n"
"/whois <nick/ID> = check a user's username\n");
fflush(stdout);
@@ -691,10 +692,18 @@ int main(int argc, char** argv)
}
else if(!strncmp(buf, "/video ", 7)) // Send video data
{
- size_t len=strtoul(&buf[7],0,10);
+ size_t len=strtoul(&buf[7],0,0);
char buf[len];
fullread(0, buf, len);
- stream_sendvideo(sock, buf, len);
+ stream_sendframe(sock, buf, len, RTMP_VIDEO);
+ continue;
+ }
+ else if(!strncmp(buf, "/audio ", 7)) // Send audio data
+ {
+ size_t len=strtoul(&buf[7],0,0);
+ char buf[len];
+ fullread(0, buf, len);
+ stream_sendframe(sock, buf, len, RTMP_AUDIO);
continue;
}
else if(!strncmp(buf, "/topic ", 7))
diff --git a/media.c b/media.c
index 50960d9..b47aa4a 100644
--- a/media.c
+++ b/media.c
@@ -1,6 +1,6 @@
/*
tc_client, a simple non-flash client for tinychat(.com)
- Copyright (C) 2015 alicia@ion.nu
+ Copyright (C) 2015-2016 alicia@ion.nu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -134,7 +134,7 @@ void stream_handlestatus(struct amf* amf, int sock)
}
}
-void stream_sendvideo(int sock, void* buf, size_t len)
+void stream_sendframe(int sock, void* buf, size_t len, unsigned char type)
{
unsigned int i;
for(i=0; i<streamcount; ++i)
@@ -142,7 +142,7 @@ void stream_sendvideo(int sock, void* buf, size_t len)
if(streams[i].outgoing)
{
struct rtmp msg;
- msg.type=RTMP_VIDEO;
+ msg.type=type;
msg.chunkid=6;
msg.length=len;
msg.msgid=streams[i].streamid;
diff --git a/media.h b/media.h
index 67a1478..8ce6048 100644
--- a/media.h
+++ b/media.h
@@ -1,6 +1,6 @@
/*
tc_client, a simple non-flash client for tinychat(.com)
- Copyright (C) 2015 alicia@ion.nu
+ Copyright (C) 2015-2016 alicia@ion.nu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -31,5 +31,5 @@ extern void streamout_start(unsigned int id, int sock); // called upon privmsg "
extern void stream_play(struct amf* amf, int sock); // called upon _result
extern void stream_handledata(struct rtmp* rtmp);
extern void stream_handlestatus(struct amf* amf, int sock);
-extern void stream_sendvideo(int sock, void* buf, size_t len);
+extern void stream_sendframe(int sock, void* buf, size_t len, unsigned char type);
extern void stream_stopvideo(int sock, unsigned int id);