Friday, 15 May 2015

objective c - Audio distorted when sending one device to another via NSStream in ios sdk -



objective c - Audio distorted when sending one device to another via NSStream in ios sdk -

hello trying record audio/video 1 device , send nsstream, have created avcapturesession , generated audio/video info . video info sent fine device , displayed right sound info distorted robotic , skipping. have got audiobufferlist cmsamplebufferref , sent thye resukting 2048 bytes info device

cmblockbufferref blockbuffer; cmsamplebuffergetaudiobufferlistwithretainedblockbuffer(samplebuffer, null, &currentinputaudiobufferlist, sizeof(currentinputaudiobufferlist), null, null, 0, &blockbuffer); if( captureoutput == _captureaudiooutput ){ (int y = 0; y < currentinputaudiobufferlist.mnumberbuffers; y++) { audiobuffer audiobuffer = currentinputaudiobufferlist.mbuffers[y]; float32 *frame = (float32*)audiobuffer.mdata; [audiodata appendbytes:frame length:audiobuffer.mdatabytesize]; } [self sendmixeddata:audiodata]; // sending audiodata } else { ////// sample buffer image nsdata [self sendmixeddata:audiodata:imagedata]; // sending images }

on other side 1 time again converting info audiobufferlist , playing audiounit services.

static osstatus playbackcallback(void *inrefcon, audiounitrenderactionflags *ioactionflags, const audiotimestamp *intimestamp, uint32 inbusnumber, uint32 innumberframes, audiobufferlist *iodata) { (int i=0; < iodata->mnumberbuffers; i++) { audiobuffer buffer = iodata->mbuffers[0]; uint32 size = min(buffer.mdatabytesize, this->tempbuffer.mdatabytesize); memcpy(buffer.mdata, this->tempbuffer.mdata, size); buffer.mdatabytesize = size; } homecoming noerr; }

here tempbuffer storing incoming sound info nsinputstream . problem the sound played distorted , robotic . have tested audiounitservices in other project record , play sound simultaneously audiounit services , sound clear there . on sending through stream becomes. disorted.

also when send sound info on stream bit clear when send both images , sound info recieved avcapturesession delegate sound distorted.please help me out . doing wrong ? can send audio/video info @ same time rather @ different times , extract on other side ?

objective-c audiounit avcapturesession avassetwriter

No comments:

Post a Comment