void BasicRTSPOnlySubsession::startStream(unsigned clientSessionId,
						void* streamToken,
						TaskFunc* rtcpRRHandler,
						void* rtcpRRHandlerClientData,
						unsigned short& rtpSeqNum,
						unsigned& rtpTimestamp,
						ServerRequestAlternativeByteHandler* serverRequestAlternativeByteHandler,
						void* serverRequestAlternativeByteHandlerClientData) {

	Destinations* dst = 
		(Destinations*)(fDestinationsHashTable->Lookup((char const*)clientSessionId));
	if (dst == NULL){
		return;
	} else {
        participant_data_t *participant;
        participant = init_participant(clientSessionId, OUTPUT, inet_ntoa(dst->addr), ntohs(dst->rtpPort.num()));
        add_participant_stream(fStream, participant);
	}
}
Ejemplo n.º 2
0
/* Add and configure a stream with a participant and an audio configuration
   into the receiver. */
static void add_receiver_entity() {
    static int count = 1;
    char name[256];
    sprintf(name, "IN_%i", count);
    participant_data_t *p = init_participant(1, INPUT, NULL, 0);
    stream_data_t *s = init_stream(AUDIO, INPUT, rand(), I_AWAIT, 0, name);
    add_participant_stream(s, p);
    ap_config(s->audio, RECEIVER_AUDIO_FORMAT_BPS,
            RECEIVER_AUDIO_FORMAT_SAMPLE_RATE,
            RECEIVER_AUDIO_FORMAT_CHANNELS,
            RECEIVER_AUDIO_FORMAT_CODEC);
    add_stream(receiver->audio_stream_list, s);
    ap_worker_start(s->audio);
    fprintf(stderr, "  ·Adding %s: %i bps, %iHz, %i channel, %s\n",
            name,
            RECEIVER_AUDIO_FORMAT_BPS,
            RECEIVER_AUDIO_FORMAT_SAMPLE_RATE,
            RECEIVER_AUDIO_FORMAT_CHANNELS,
            get_name_to_audio_codec(RECEIVER_AUDIO_FORMAT_CODEC));
    count++;
}
Ejemplo n.º 3
0
DDS::DomainParticipant_var
TestBase::create_participant()
{
  DDS::DomainId_t domain = DEFAULT_DOMAIN;

  DDS::DomainParticipantQos qos;
  DDS::DomainParticipantFactory_var dpf = TheParticipantFactory;
  if (dpf->get_default_participant_qos(qos) != DDS::RETCODE_OK) {
    ACE_ERROR((LM_ERROR,
               ACE_TEXT("ERROR: %N:%l: create_participant() -")
               ACE_TEXT(" get_default_participant_qos failed!\n")));
    ACE_OS::exit(-1);
  }

  DDS::DomainParticipantListener_ptr listener =
    DDS::DomainParticipantListener::_nil();

  DDS::StatusMask status = OpenDDS::DCPS::DEFAULT_STATUS_MASK;

  if (init_participant(domain, qos, listener, status) != DDS::RETCODE_OK) {
    ACE_ERROR((LM_ERROR,
               ACE_TEXT("ERROR: %N:%l: create_participant() -")
               ACE_TEXT(" init_participant failed!\n")));
    ACE_OS::exit(-1);
  }

  DDS::DomainParticipant_var participant =
    dpf->create_participant(domain, qos, listener, status);

  if (CORBA::is_nil(participant.in())) {
    ACE_ERROR((LM_ERROR,
               ACE_TEXT("ERROR: %N:%l: create_participant() -")
               ACE_TEXT(" create_participant failed!\n")));
    ACE_OS::exit(-1);
  }

  return participant;
}
Ejemplo n.º 4
0
/* Add and configure a stream with a participant and an audio configuration
   into the transmitter. */
static void add_transmitter_entity(char *ip, int port) {
    static int count = 1;
    char name[256];
    sprintf(name, "OUT_%i", count);
    participant_data_t *p = init_participant(0, OUTPUT, ip, port);
    stream_data_t *s = init_stream(AUDIO, OUTPUT, 0, ACTIVE, 0, name);
    add_participant_stream(s, p);
    ap_config(s->audio, TRANSMITTER_AUDIO_FORMAT_BPS,
            TRANSMITTER_AUDIO_FORMAT_SAMPLE_RATE,
            TRANSMITTER_AUDIO_FORMAT_CHANNELS,
            TRANSMITTER_AUDIO_FORMAT_CODEC);
    add_stream(transmitter->audio_stream_list, s);
    ap_worker_start(s->audio);
    fprintf(stderr,
            "  ·Adding %s: %i bps, %iHz, %i channel, %s, to addr %s:%i\n",
            name,
            TRANSMITTER_AUDIO_FORMAT_BPS,
            TRANSMITTER_AUDIO_FORMAT_SAMPLE_RATE,
            TRANSMITTER_AUDIO_FORMAT_CHANNELS,
            get_name_to_audio_codec(TRANSMITTER_AUDIO_FORMAT_CODEC),
            ip,
            port);
    count++;
}
Ejemplo n.º 5
0
int main() {

    fprintf(stderr, "Starting audio_receiver test...\n");

    // Open files to write audio
    if ((F_audio1 = fopen(name_audio1, "wb")) == NULL) {
        perror(name_audio1);
        exit(errno);
    }
    if ((F_audio2 = fopen(name_audio2, "wb")) == NULL) {
        perror(name_audio2);
        exit(errno);
    }

    // General pourpouse variables.
    time_t start, stop;
    audio_frame2 *audio_frame;

    // Receiver configuration
    stream_list_t *video_stream_list = init_stream_list(); // Not used
    stream_list_t *audio_stream_list = init_stream_list();
    receiver_t *receiver = init_receiver(video_stream_list, audio_stream_list, 5004, 5006);

    // First stream and participant configuration
    participant_data_t *p1 = init_participant(1, INPUT, NULL, 0);
    stream_data_t *stream1 = init_stream(AUDIO, INPUT, rand(), I_AWAIT, 25.0, "Stream1");
    add_participant_stream(stream1, p1);
    add_stream(receiver->audio_stream_list, stream1);
    fprintf(stderr, " ·Stream1 configuration: 1 bps, 32000Hz, 1 channel, mulaw\n");
    ap_config(stream1->audio, 1, 32000, 1, AC_MULAW);
    ap_worker_start(stream1->audio);

    // Second stream and participant configuration
    participant_data_t *p2 = init_participant(2, INPUT, NULL, 0);
    stream_data_t *stream2 = init_stream(AUDIO, INPUT, rand(), I_AWAIT, 25.0, "Stream2");
    add_participant_stream(stream2, p2);
    add_stream(receiver->audio_stream_list, stream2);
    fprintf(stderr, " ·Stream2 configuration: 1 bps, 8000Hz, 1 channel, mulaw\n");
    ap_config(stream2->audio, 1, 8000, 1, AC_MULAW);
    ap_worker_start(stream2->audio);

    if (start_receiver(receiver)) {
        fprintf(stderr, " ·Receiver started!\n");

#ifdef STREAM1
        // STREAM1 recording block
        fprintf(stderr, "  ·Waiting for audio_frame2 data\n");
        while (stream1->audio->decoded_cq->level == CIRCULAR_QUEUE_EMPTY) {
#ifdef QUEUE_PRINT
            print_cq_status(stream1->audio->decoded_cq, "wait stream1");
#endif
        }
#ifdef QUEUE_PRINT
        print_cq_status(stream1->audio->decoded_cq, "continue stream1");
#endif

        fprintf(stderr, "   ·Copying to file... ");
        start = time(NULL);
        stop = start + RECORD_TIME;
        while (time(NULL) < stop) { // RECORD_TIME seconds loop
            audio_frame = cq_get_front(stream1->audio->decoded_cq);
            if (audio_frame != NULL) {
                fwrite(audio_frame->data[0], audio_frame->data_len[0], 1, F_audio1);
                cq_remove_bag(stream1->audio->decoded_cq);
            }
        }
        fprintf(stderr, "Done!\n");
#endif //STREAM1

#ifdef STREAM2
        // STREAM2 recording block
        fprintf(stderr, "  ·Waiting for audio_frame2 data\n");
        while (stream2->audio->decoded_cq->level == CIRCULAR_QUEUE_EMPTY) {
#ifdef QUEUE_PRINT
            print_cq_status(stream2->audio->decoded_cq, "wait stream2");
#endif
        }
#ifdef QUEUE_PRINT
        print_cq_status(stream2->audio->decoded_cq, "continue stream2");
#endif
        fprintf(stderr, "   ·Copying to file... ");
        start = time(NULL);
        stop = start + RECORD_TIME;
        while (time(NULL) < stop) { // RECORD_TIME seconds loop
            audio_frame = cq_get_front(stream2->audio->decoded_cq);
            if (audio_frame != NULL) {
                fwrite(audio_frame->data[0], audio_frame->data_len[0], 1, F_audio2);
                cq_remove_bag(stream2->audio->decoded_cq);
            }
        }
        fprintf(stderr, "Done!\n");
#endif //STREAM2

        // Finish and destroy objects
        stop_receiver(receiver);
        destroy_receiver(receiver);
        fprintf(stderr, " ·Receiver stopped\n");
        destroy_stream_list(video_stream_list);
        destroy_stream_list(audio_stream_list);
    }

    if (fclose(F_audio1) != 0) {
        perror(name_audio1);
        exit(-1);
    }
    if (fclose(F_audio2) != 0) {
        perror(name_audio2);
        exit(-1);
    }
    fprintf(stderr, "Finished\n");
}