summaryrefslogtreecommitdiff
path: root/src/inputstreamer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/inputstreamer.cc')
-rw-r--r--src/inputstreamer.cc43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/inputstreamer.cc b/src/inputstreamer.cc
index 3ddf36e..fdc5d2a 100644
--- a/src/inputstreamer.cc
+++ b/src/inputstreamer.cc
@@ -29,20 +29,23 @@
#include <QApplication>
#include <unistd.h>
-#define KEY "123456789012345678901234567890123456789012345678901234567890"
-#define SSRC 1234567890
#define CSRC_V 42
#define CSRC_A 43
-InputStreamer::InputStreamer(QHostAddress addr, quint16 port)
+InputStreamer::InputStreamer(int peer, QString peer_name,
+ QHostAddress addr, quint16 port,
+ QString key, unsigned int ssrc)
// : socket(this)
{
- total = 0;
-
-
+ this->peer = peer;
+ this->peer_name = peer_name;
+ this->key = key;
+ this->ssrc = ssrc;
this->addr = addr;
this->port = port;
+ total = 0;
+
name.sin_family = AF_INET;
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(sock < 0) {
@@ -87,15 +90,18 @@ void InputStreamer::run()
{
lrtp_status_t status;
- lrtp = lrtp_init(&status, KEY, SSRC);
- if(status != LRTP_OK) printf("O:lrtp_init err: %d\n", status);
+ char ckey[61];
+ strcpy(ckey, key.toStdString().c_str());
+
+ lrtp = lrtp_init(&status, ckey, ssrc);
+ if(status != LRTP_OK) printf("I:lrtp_init err: %d\n", status);
int res;
res = lrtp_create_profile(lrtp, PROFILE_JPEG, CSRC_V, OPTION_END);
- if(res != 0) printf("O:lrtp_create_profile (v) err: %d\n", res);
+ if(res != 0) printf("I:lrtp_create_profile (v) err: %d\n", res);
res = lrtp_create_profile(lrtp, PROFILE_OPUS, CSRC_A, OPTION_END);
- if(res != 0) printf("O:lrtp_create_profile (a) err: %d\n", res);
+ if(res != 0) printf("I:lrtp_create_profile (a) err: %d\n", res);
char packet[64*1024];
while(running) {
@@ -141,18 +147,18 @@ void InputStreamer::run()
unsigned int ts;
while((ret = lrtp_dequeue_frame(lrtp, frame, sizeof(frame), &csrc, &ts))
!= 0) {
- if(ret < 0) printf("\nlrtp_dequeue_frame: %d\n", ret);
+ if(ret < 0) printf("I:lrtp_dequeue_frame: %d\n", ret);
if(csrc == CSRC_V) {
// Video frame
Frame f(frame, ret);
f.ts = ts;
- emit newImage(f);
+ emit newImage(peer, f);
//printf("v"); fflush(stdout);
} else if(csrc == CSRC_A) {
// Audio frame
Frame f(frame, ret);
f.ts = ts;
- emit newAudio(f);
+ emit newAudio(peer, f);
//printf("a"); fflush(stdout);
} else {
printf("Unknown stream: CSRC: %d\n", csrc);
@@ -163,13 +169,13 @@ void InputStreamer::run()
printf("done\n");
status = lrtp_destroy_profile(lrtp, CSRC_V);
- if(status != LRTP_OK) printf("O:lrtp_destroy_profile (v) err: %d\n", status);
+ if(status != LRTP_OK) printf("I:lrtp_destroy_profile (v) err: %d\n", status);
status = lrtp_destroy_profile(lrtp, CSRC_A);
- if(status != LRTP_OK) printf("O:lrtp_destroy_profile (a) err: %d\n", status);
+ if(status != LRTP_OK) printf("I:lrtp_destroy_profile (a) err: %d\n", status);
status = lrtp_close(lrtp);
- if(status != LRTP_OK) printf("O:lrtp_close err: %d\n", status);
+ if(status != LRTP_OK) printf("I:lrtp_close err: %d\n", status);
}
size_t InputStreamer::getTotal()
@@ -178,3 +184,8 @@ size_t InputStreamer::getTotal()
total = 0;
return t;
}
+
+QString InputStreamer::getName()
+{
+ return peer_name;
+}