On Mon, Aug 10, 2009 at 11:34 AM, Angelica Grace Tanchico<atanchico at live.com> wrote: > > Hello, > > I am trying to create a copy of a wav file using the > function?pjmedia_port_get_frame() and?pjmedia_port_put_frame. > > I have this code below. After the wav file is read (EOF), I tried listening > to the > > new created (copy) wav file. But the file cannot be opened. I think it is > not copied/created > > properly (since filesize does not match). > > Can you help me? Where did I possibly go wrong? > The only thing I can think of is because the (writer) media port is not closed/destroyed? We only fix the WAVE header when the port is closed, since we wouldn't know the audio length in advance. Closing the port also flushes the port's internal buffer. Cheers Benny > Thanks in advance! :) > > << snip >> > > pjmedia_port *player, *writer; > > pj_status_t status; > > status = pjmedia_wav_player_port_create(pool,?WAV_FILE_PLAYER, 20, 1, 0,?0, > &player); > > PJ_ASSERT_RETURN(status==PJ_SUCCESS, PJ_SUCCESS); > > status = pjmedia_wav_writer_port_create(pool, > > WAV_FILE_REC, > > player->info.clock_rate, > > player->info.channel_count, > > player->info.samples_per_frame, > > player->info.bits_per_sample, > > 0, > > 0, > > &writer); > > ?? ? ? ?int bpf = player->info.samples_per_frame * > player->info.bits_per_sample / 16; > > while (1) { > > pj_int16_t samplebuf[bpf]; > > pjmedia_frame frame; > > pj_status_t status; > > frame.buf = samplebuf; > > frame.size = sizeof(samplebuf); > > status = pjmedia_port_get_frame(player, &frame); > > if (status != PJ_SUCCESS || frame.type == PJMEDIA_FRAME_TYPE_NONE) { > > // End-of-file, end the conversion. > > break; > > } > > // Put the frame to write port. > > status = pjmedia_port_put_frame(writer, &frame); > > if (status != PJ_SUCCESS) { > > break; > > } > > }//while > > << snip >> > > > Regards, > > Anj > > > ________________________________ > Party with Buddy! Bling out your Messenger with free winks & emoticons. > Click here > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > >