Here is some sample code for how to change cameras using the DG_CONTROL / DAT_FILESYSTEM operations.

 

 

TW_FILESYSTEM fs;

TW_STR255 cameraname[3];

 

// For loop used to discover available cameras...

memset(cameraname,0,sizeof(cameraname));

for (rc = (*pDSM_Entry)

            (&AppId,&SourceId,

             DG_CONTROL,

             DAT_FILESYSTEM,

             MSG_GETFIRSTFILE,(TW_MEMREF)&fs);

     rc == TWRC_SUCCESS;

     rc = (*pDSM_Entry)

            (&AppId,&SourceId,

             DG_CONTROL,

             DAT_FILESYSTEM,

             MSG_GETNEXTFILE,(TW_MEMREF)&fs)) {

 

      // This is the combined front / rear camera...

      // In each case, just take the first one we find...

      if (fs.FileType == TWFY_CAMERA) {

            if (!cameraname[0][0]) strcpy(cameraname[0],fs.OutputName);

      // This is the front camera...

      } else if (fs.FileType == TWFY_CAMERA_TOP) {

            if (!cameraname[1][0]) strcpy(cameraname[1],fs.OutputName);

      // This is the rear camera...

      } else if (fs.FileType == TWFY_CAMERA_BOTTOM) {

            if (!cameraname[2][0]) strcpy(cameraname[2],fs.OutputName);

      }

}

 

// Change to the front camera...

strcpy(fs.InputName,cameraname[1]);

rc = (*pDSM_Entry)

      (&AppId,&SourceId,

       DG_CONTROL,

       DAT_FILESYSTEM,

       MSG_CHANGEDIRECTORY,(TW_MEMREF)&fs);

// Set some front capabilities, like ICAP_CONTRAST

...

 

// Change to the rear camera...

strcpy(fs.InputName,cameraname[2]);

rc = (*pDSM_Entry)

      (&AppId,&SourceId,

       DG_CONTROL,

       DAT_FILESYSTEM,

       MSG_CHANGEDIRECTORY,(TW_MEMREF)&fs);

// Set some rear capabilities, like ICAP_CONTRAST

...

 

// Change back to the combined camera (have to do

// this before scanning starts, but can also do

// this to simultaneously change front and rear

// values).  Note that this is the default camera

// when the Source is first started...

strcpy(fs.InputName,cameraname[0]);

rc = (*pDSM_Entry)

      (&AppId,&SourceId,

       DG_CONTROL,

       DAT_FILESYSTEM,

       MSG_CHANGEDIRECTORY,(TW_MEMREF)&fs);

...