[server] / trunk / server / src / mmdevice.cxx Repository:
ViewVC logotype

Diff of /trunk/server/src/mmdevice.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 392, Mon Sep 14 08:57:35 2009 UTC revision 393, Mon Sep 14 12:49:47 2009 UTC
# Line 99  Line 99 
99          LOGDEBUG("MmDevice::listen() device: " << devName_ <<          LOGDEBUG("MmDevice::listen() device: " << devName_ <<
100                   " other: " << other->getDeviceName());                   " other: " << other->getDeviceName());
101    
102    /*
103          if ( dev_Connect(devHandle_, other->getDeviceHandle(), DM_FULLDUP, EV_ASYNC) < 0 )          if ( dev_Connect(devHandle_, other->getDeviceHandle(), DM_FULLDUP, EV_ASYNC) < 0 )
104          {          {
105                  LOGERROR("dev_Connect() failed");                  LOGERROR("dev_Connect() failed");
106                  return false;                  return false;
107          }          }
108    
109            return true;
110    */
111            if ( listening_ != other )
112            {
113    
114                    DM_PORT_CONNECT_INFO_LIST portConnectInfoList;
115                    INIT_DM_PORT_CONNECT_INFO_LIST(&portConnectInfoList);
116    
117                    int count = 0;
118    
119                    INIT_DM_PORT_CONNECT_INFO(&portConnectInfoList.port_connect_info[count]);
120                    portConnectInfoList.port_connect_info[count].unFlags = DMFL_TRANSCODE_ON;
121                    portConnectInfoList.port_connect_info[count].port_info_tx = getAudioTxPortInfo();
122                    portConnectInfoList.port_connect_info[count].port_info_rx = ((IpmDevice*)other)->getAudioRxPortInfo(); //XXX
123                    count++;
124    
125                    INIT_DM_PORT_CONNECT_INFO(&portConnectInfoList.port_connect_info[count]);
126                    portConnectInfoList.port_connect_info[count].unFlags = DMFL_TRANSCODE_ON;
127                    portConnectInfoList.port_connect_info[count].port_info_tx = getVideoTxPortInfo();
128                    portConnectInfoList.port_connect_info[count].port_info_rx = ((IpmDevice*)other)->getVideoRxPortInfo(); //XXX
129                    count++;
130    
131                    portConnectInfoList.unCount = count;;
132                    if ( dev_PortConnect(devHandle_, &portConnectInfoList, NULL) != DEV_SUCCESS )
133                    {
134                            LOGERROR("dev_PortConnect() failed on device: " << devName_ <<
135                                     " " << ATDV_ERRMSGP(devHandle_));
136                            return false;
137                    }
138    
139                    listening_ = other;
140            }
141          return true;          return true;
142  }  }
143    
# Line 114  Line 148 
148  bool MmDevice::unListen()  bool MmDevice::unListen()
149  {  {
150          LOGDEBUG("MmDevice::unListen() device: " << devName_);          LOGDEBUG("MmDevice::unListen() device: " << devName_);
151    /*
152          if ( dev_Disconnect(devHandle_, EV_ASYNC) < 0 )          if ( dev_Disconnect(devHandle_, EV_ASYNC) < 0 )
153          {          {
154                  LOGERROR("dev_Connect() failed");                  LOGERROR("dev_Connect() failed");
155                  return false;                  return false;
156          }          }
157          return true;          return true;
158    */
159            if ( listening_ )
160            {
161                    DM_PORT_CONNECT_INFO_LIST portConnectInfoList;
162                    INIT_DM_PORT_CONNECT_INFO_LIST(&portConnectInfoList);
163                    int count = 0;
164    
165                    INIT_DM_PORT_CONNECT_INFO(&portConnectInfoList.port_connect_info[count]);
166                    portConnectInfoList.port_connect_info[count].port_info_tx = getAudioTxPortInfo();
167                    portConnectInfoList.port_connect_info[count].port_info_rx = ((IpmDevice*)listening_)->getAudioRxPortInfo(); //XXX
168                    count++;
169    
170                    INIT_DM_PORT_CONNECT_INFO(&portConnectInfoList.port_connect_info[count]);
171                    portConnectInfoList.port_connect_info[count].port_info_tx = getVideoTxPortInfo();
172                    portConnectInfoList.port_connect_info[count].port_info_rx = ((IpmDevice*)listening_)->getVideoRxPortInfo(); //XXX
173                    count++;
174    
175                    portConnectInfoList.unCount = count;
176                    if ( dev_PortDisconnect(devHandle_, &portConnectInfoList, NULL) != DEV_SUCCESS )
177                    {
178                            LOGERROR("dev_PortDisconnect() failed on device: " << devName_ <<
179                                     " " << ATDV_ERRMSGP(devHandle_));
180                            return false;
181                    }
182    
183                    listening_ = 0;
184            }
185            return true;
186  }  }
187    
188    
# Line 133  Line 196 
196          switch ( evttype )          switch ( evttype )
197          {          {
198                  case MMEV_OPEN:                  case MMEV_OPEN:
199                          LOGDEBUG("MmDevice::processEvent() MMEV_OPEN device: " << devName_);                          onOpen();
200                          break;                          break;
201    
202                  case MMEV_PLAY:                  case MMEV_PLAY: /* mm_Play() completed successfully */
203                          onPlay();                          onPlay();
204                          break;                          break;
205    
206                    case MMEV_PLAY_ACK: /* mm_Play() started successfully */
207                            LOGDEBUG("MmDevice::processEvent() MMEV_PLAY_ACK device: " << devName_);
208                            break;
209    
210                  case MMEV_PLAY_FAIL:                  case MMEV_PLAY_FAIL:
211                          onPlayFail();                          onPlayFail();
212                          break;                          break;
# Line 180  Line 247 
247                  case DMEV_PORT_DISCONNECT_FAIL:                  case DMEV_PORT_DISCONNECT_FAIL:
248                          break;                          break;
249    
250                    case DMEV_GET_TX_PORT_INFO:
251                            onGetTxPortInfo((DM_PORT_INFO_LIST*)sr_getevtdatap());
252                            break;
253    
254                    case DMEV_GET_RX_PORT_INFO:
255                            onGetRxPortInfo((DM_PORT_INFO_LIST*)sr_getevtdatap());
256                            break;
257    
258                  default:                  default:
259                          LOGDEBUG("MmDevice::processEvent() Unhandled event: " << evttype <<                          LOGDEBUG("MmDevice::processEvent() Unhandled event: " <<
260                                   " " << ATDV_NAMEP(sr_getevtdev()));                                   std::hex << evttype << " " << ATDV_NAMEP(sr_getevtdev()));
261                          break;                          break;
262          }          }
263          return true;          return true;
# Line 190  Line 265 
265    
266    
267  /*  /*
268     * Handle MMEV_OPEN event.
269     */
270    void MmDevice::onOpen()
271    {
272            LOGDEBUG("MmDevice::processEvent() MMEV_OPEN device: " << devName_);
273    
274            /* Request port info
275             */
276            if ( dev_GetTransmitPortInfo(devHandle_, this) == -1 )
277            {
278                    LOGERROR("dev_GetTransmitPortInfo() failed");
279            }
280            if ( dev_GetReceivePortInfo(devHandle_, this) == -1 )
281            {
282                    LOGERROR("dev_GetReceivePortInfo() failed");
283            }
284    }
285    
286    
287    /*
288   * Handle MMEV_PLAY event.   * Handle MMEV_PLAY event.
289   */   */
290  void MmDevice::onPlay()  void MmDevice::onPlay()
291  {  {
292          LOGINFO("MmDevice::onPlay()");          LOGINFO("MmDevice::onPlay() device: " << devName_);
293  }  }
294    
295    
# Line 203  Line 298 
298   */   */
299  void MmDevice::onPlayAckFail()  void MmDevice::onPlayAckFail()
300  {  {
301          LOGINFO("MmDevice::onPlayAckFail()");          LOGWARN("MmDevice::onPlayAckFail() device: " << devName_);
302  }  }
303    
304    
# Line 212  Line 307 
307   */   */
308  void MmDevice::onPlayFail()  void MmDevice::onPlayFail()
309  {  {
310          LOGINFO("MmDevice::onPlayFail()");          LOGINFO("MmDevice::onPlayFail() device: " << devName_);
311  }  }
312    
313    
# Line 221  Line 316 
316   */   */
317  void MmDevice::onRecordAck()  void MmDevice::onRecordAck()
318  {  {
319          LOGINFO("MmDevice::onRecordAck()");          LOGINFO("MmDevice::onRecordAck() device: " << devName_);
320  }  }
321    
322    
# Line 230  Line 325 
325   */   */
326  void MmDevice::onStopAck()  void MmDevice::onStopAck()
327  {  {
328          LOGINFO("MmDevice::onStopAck()");          LOGINFO("MmDevice::onStopAck() device: " << devName_);
329  }  }
330    
331    
# Line 239  Line 334 
334   */   */
335  void MmDevice::onStopAckFail()  void MmDevice::onStopAckFail()
336  {  {
337          LOGINFO("MmDevice::onStopAckFail()");          LOGWARN("MmDevice::onStopAckFail() device: " << devName_);
338  }  }
339    
340    
# Line 248  Line 343 
343   */   */
344  void MmDevice::onReset()  void MmDevice::onReset()
345  {  {
346          LOGINFO("MmDevice::onReset()");          LOGINFO("MmDevice::onReset() device: " << devName_);
347  }  }
348    
349    
# Line 257  Line 352 
352   */   */
353  void MmDevice::onError()  void MmDevice::onError()
354  {  {
355          LOGINFO("MmDevice::onError()");          LOGINFO("MmDevice::onError() device: " << devName_);
356  }  }
357    
358    
359    /*
360     * Handler for DMEV_GET_TX_PORT_INFO events.
361     */
362    void MmDevice::onGetTxPortInfo(DM_PORT_INFO_LIST* portInfoList )
363    {
364            LOGINFO("MmDevice::onGetTxPortInfo() device: " << devName_);
365    
366            txPortInfoList_ = *portInfoList;
367            printPortInfo(&txPortInfoList_);
368    
369            for ( unsigned int i = 0; i < txPortInfoList_.unCount; i++ )
370            {
371                    switch ( txPortInfoList_.port_info[i].port_media_type )
372                    {
373                            case DM_PORT_MEDIA_TYPE_AUDIO:
374                                    memcpy(&audioPortTxInfo_, &txPortInfoList_.port_info[i], sizeof(DM_PORT_INFO));
375                                    break;
376    
377                            case DM_PORT_MEDIA_TYPE_VIDEO:
378                                    memcpy(&videoPortTxInfo_, &txPortInfoList_.port_info[i], sizeof(DM_PORT_INFO));
379                                    break;
380    
381                            default:
382                                    break;
383                    }
384            }
385    }
386    
387    
388    /*
389     * Handler for DMEV_GET_RX_PORT_INFO events.
390     */
391    void MmDevice::onGetRxPortInfo(DM_PORT_INFO_LIST* portInfoList )
392    {
393            LOGINFO("MmDevice::onGetRxPortInfo() device: " << devName_);
394    
395            rxPortInfoList_ = *portInfoList;
396            printPortInfo(&rxPortInfoList_);
397    
398            for ( unsigned int i = 0; i < rxPortInfoList_.unCount; i++ )
399            {
400                    switch ( rxPortInfoList_.port_info[i].port_media_type )
401                    {
402                            case DM_PORT_MEDIA_TYPE_AUDIO:
403                                    memcpy(&audioPortRxInfo_, &rxPortInfoList_.port_info[i], sizeof(DM_PORT_INFO));
404                                    break;
405    
406                            case DM_PORT_MEDIA_TYPE_VIDEO:
407                                    memcpy(&videoPortRxInfo_, &rxPortInfoList_.port_info[i], sizeof(DM_PORT_INFO));
408                                    break;
409    
410                            default:
411                                    break;
412                    }
413            }
414    }
415    
416    
417    /*
418     * Debug aid.
419     */
420    void MmDevice::printPortInfo( DM_PORT_INFO_LIST* portInfo ) const
421    {
422            std::stringstream ss;
423    
424            for ( unsigned int i = 0; i < portInfo->unCount; i++ )
425            {
426                    DM_PORT_INFO& info = portInfo->port_info[i];
427                    ss << "Port: " << i << " MediaType: " << info.port_media_type << " ";
428                    if ( info.port_media_type == DM_PORT_MEDIA_TYPE_AUDIO )
429                    {
430                            ss << "Audio";
431                    }
432                    else if ( info.port_media_type == DM_PORT_MEDIA_TYPE_VIDEO )
433                    {
434                            ss << "Video";
435                    }
436                    else if ( info.port_media_type == DM_PORT_MEDIA_TYPE_NBUP )
437                    {
438                            ss << "NBUP";
439                    }
440                    else
441                    {
442                            ss << info.port_media_type;
443                    }
444                    ss << std::endl;
445            }
446            LOGDEBUG(ss.str());
447    }
448    
449    
450  /*  /*
451   * Start playing.   * Start playing.
# Line 292  Line 477 
477                  playRecordList_[0].list = &audioMediaList_;                  playRecordList_[0].list = &audioMediaList_;
478                  playRecordList_[0].ItemChain = EMM_ITEM_EOT;                  playRecordList_[0].ItemChain = EMM_ITEM_EOT;
479    
480                  INIT_MM_PLAY_RECORD_INFO(&playInfo_);                  INIT_MM_PLAY_INFO(&playInfo_);
481                  playInfo_.eFileFormat = EMM_FILE_FORMAT_UNDEFINED;                  playInfo_.eFileFormat = EMM_FILE_FORMAT_UNDEFINED;
482                  playInfo_.list  = playRecordList_;                  playInfo_.list  = playRecordList_;
483          }          }
# Line 382  Line 567 
567          audioMediaList_.item.audio.szFileName = audioFile.c_str();          audioMediaList_.item.audio.szFileName = audioFile.c_str();
568          videoMediaList_.item.video.szFileName = videoFile.c_str();          videoMediaList_.item.video.szFileName = videoFile.c_str();
569    
570          LOGINFO("Playing from: " << audioMediaList_.item.audio.szFileName << ", " << videoMediaList_.item.video.szFileName);          LOGDEBUG("Playing: a=" << audioMediaList_.item.audio.szFileName <<
571                     ", v=" << videoMediaList_.item.video.szFileName);
572          if ( mm_Play(devHandle_, &playInfo_, NULL, NULL) == EMM_ERROR )          if ( mm_Play(devHandle_, &playInfo_, NULL, NULL) == EMM_ERROR )
573          {          {
574                  LOGERROR("mm_Play() failed on device: " << getDeviceName());                  LOGERROR("mm_Play() failed on device: " << getDeviceName());
# Line 482  Line 668 
668          playRecordList_[1].list = &videoMediaList_;          playRecordList_[1].list = &videoMediaList_;
669          playRecordList_[1].ItemChain = EMM_ITEM_EOT;          playRecordList_[1].ItemChain = EMM_ITEM_EOT;
670    
671          INIT_MM_PLAY_RECORD_INFO(&recordInfo_);          INIT_MM_RECORD_INFO(&recordInfo_);
672          recordInfo_.eFileFormat = EMM_FILE_FORMAT_UNDEFINED;          recordInfo_.eFileFormat = EMM_FILE_FORMAT_UNDEFINED;
673          recordInfo_.list = playRecordList_;          recordInfo_.list = playRecordList_;
674    
675          //sendIFrameRequest();          // XXX sendIFrameRequest();
676    
677          LOGINFO("Recording to: " << audioMediaList_.item.audio.szFileName << ", " << videoMediaList_.item.video.szFileName);          LOGDEBUG("Recording: a=" << audioMediaList_.item.audio.szFileName <<
678                     ", v=" << videoMediaList_.item.video.szFileName);
679          if ( mm_Record(devHandle_, &recordInfo_, NULL, 0) == EMM_ERROR )          if ( mm_Record(devHandle_, &recordInfo_, NULL, 0) == EMM_ERROR )
680          {          {
681                  LOGERROR("mm_Record() failed on device: " << getDeviceName());                  LOGERROR("mm_Record() failed on device: " << getDeviceName());

Legend:
Removed from v.392  
changed lines
  Added in v.393

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.8