コード例 #1
0
ファイル: Cli.php プロジェクト: NicolasSchmutz/cm
 /**
  * @param int     $streamChannelId
  * @param CM_File $thumbnailSource
  */
 public function importVideoThumbnail($streamChannelId, CM_File $thumbnailSource)
 {
     $streamChannel = CM_Model_StreamChannel_Video::factory($streamChannelId);
     $thumbnailCount = $streamChannel->getThumbnailCount();
     $thumbnailDestination = $streamChannel->getThumbnail($thumbnailCount + 1);
     if (0 == $thumbnailCount) {
         $thumbnailDestination->ensureParentDirectory();
     }
     $thumbnailSource->copyToFile($thumbnailDestination);
     $streamChannel->setThumbnailCount($thumbnailCount + 1);
 }
コード例 #2
0
ファイル: VideoTest.php プロジェクト: NicolasSchmutz/cm
 public function testNonexistentServerId()
 {
     /** @var CM_Model_StreamChannel_Video $channel */
     $channel = CM_Model_StreamChannel_Video::createStatic(array('key' => 'foobar', 'width' => 100, 'height' => 200, 'serverId' => 800, 'thumbnailCount' => 2, 'adapterType' => 1));
     try {
         $channel->getPublicHost();
         $this->fail('Found server with Id 800');
     } catch (CM_Exception $ex) {
         $this->assertSame("No video server with id `800` found", $ex->getMessage());
     }
 }
コード例 #3
0
ファイル: TypeTest.php プロジェクト: NicolasSchmutz/cm
 public function testPaging()
 {
     CMTest_TH::createStreamChannelVideoArchive();
     $archive = CMTest_TH::createStreamChannelVideoArchive();
     CMTest_TH::timeForward(30);
     CMTest_TH::createStreamChannelVideoArchive();
     /** @var CM_Model_StreamChannel_Video $streamChannel */
     $streamChannel = CMTest_TH::createStreamChannel();
     $streamChannel = $this->getMock('CM_Model_StreamChannel_Video', array('getType'), array($streamChannel->getId()));
     $streamChannel->expects($this->any())->method('getType')->will($this->returnValue(3));
     CMTest_TH::createStreamChannelVideoArchive($streamChannel);
     $paging = new CM_Paging_StreamChannelArchiveVideo_Type(CM_Model_StreamChannel_Video::getTypeStatic());
     $this->assertSame(3, $paging->getCount());
     $paging = new CM_Paging_StreamChannelArchiveVideo_Type($streamChannel->getType());
     $this->assertSame(1, $paging->getCount());
     $paging = new CM_Paging_StreamChannelArchiveVideo_Type(CM_Model_StreamChannel_Video::getTypeStatic(), $archive->getCreated());
     $this->assertSame(2, $paging->getCount());
 }
コード例 #4
0
 protected function _processItem($item)
 {
     return $this->_streamChannel->getThumbnail($item);
 }
コード例 #5
0
ファイル: TH.php プロジェクト: aladin1394/CM
 /**
  * @param int|null $type
  * @param int|null $adapterType
  * @return CM_Model_StreamChannel_Abstract
  */
 public static function createStreamChannel($type = null, $adapterType = null)
 {
     if (null === $type) {
         $type = CM_Model_StreamChannel_Video::getTypeStatic();
     }
     if (null === $adapterType) {
         $adapterType = CM_Stream_Adapter_Video_Wowza::getTypeStatic();
     }
     $data = array('key' => rand(1, 10000) . '_' . rand(1, 100));
     if (CM_Model_StreamChannel_Video::getTypeStatic() == $type) {
         $data['width'] = 480;
         $data['height'] = 720;
         $data['serverId'] = 1;
         $data['thumbnailCount'] = 0;
         $data['adapterType'] = $adapterType;
     }
     return CM_Model_StreamChannel_Abstract::createType($type, $data);
 }
コード例 #6
0
ファイル: AbstractTest.php プロジェクト: NicolasSchmutz/cm
 /**
  * @expectedException CM_Exception_Invalid
  * @expectedExceptionMessage Unexpected instance of
  */
 public function testFactoryInvalidInstance()
 {
     $messageStreamChannel = CM_Model_StreamChannel_Message::createStatic(array('key' => 'message-stream-channel', 'adapterType' => CM_MessageStream_Adapter_SocketRedis::getTypeStatic()));
     CM_Model_StreamChannel_Video::factory($messageStreamChannel->getId());
 }
コード例 #7
0
ファイル: VideoTest.php プロジェクト: NicolasSchmutz/cm
 public function testDeleteOlder()
 {
     $time = time();
     /** @var CM_Model_StreamChannel_Video $streamChannel */
     $streamChannelsDeleted = array();
     $archivesDeleted = array();
     /** @var $filesDeleted CM_File[] */
     $filesDeleted = array();
     for ($i = 0; $i < 2; $i++) {
         $streamChannel = CMTest_TH::createStreamChannel();
         $streamChannel->setThumbnailCount(4);
         $streamChannelsDeleted[] = $streamChannel;
         $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
         $archivesDeleted[] = $archive;
         $filesDeleted = array_merge($filesDeleted, $this->_createArchiveFiles($archive));
     }
     $streamChannelsNotDeleted = array();
     $archivesNotDeleted = array();
     /** @var $filesNotDeleted CM_File[] */
     $filesNotDeleted = array();
     $streamChannel = CMTest_TH::createStreamChannel();
     $streamChannel = $this->getMock('CM_Model_StreamChannel_Video', array('getType'), array($streamChannel->getId()));
     $streamChannel->expects($this->any())->method('getType')->will($this->returnValue(3));
     $streamChannelsNotDeleted[] = $streamChannel;
     $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
     $archivesNotDeleted[] = $archive;
     $filesNotDeleted = array_merge($filesNotDeleted, $this->_createArchiveFiles($archive));
     CMTest_TH::timeForward(20);
     for ($i = 0; $i < 3; $i++) {
         $streamChannel = CMTest_TH::createStreamChannel();
         $streamChannel->setThumbnailCount(4);
         $streamChannelsNotDeleted[] = $streamChannel;
         $archive = CMTest_TH::createStreamChannelVideoArchive($streamChannel);
         $archivesNotDeleted[] = $archive;
         $filesNotDeleted = array_merge($filesNotDeleted, $this->_createArchiveFiles($archive));
     }
     foreach ($filesNotDeleted as $file) {
         $this->assertTrue($file->exists());
     }
     foreach ($filesDeleted as $file) {
         $this->assertTrue($file->exists());
     }
     CM_Model_StreamChannelArchive_Video::deleteOlder(10, CM_Model_StreamChannel_Video::getTypeStatic());
     foreach ($filesNotDeleted as $file) {
         $this->assertTrue($file->exists());
     }
     foreach ($filesDeleted as $file) {
         $this->assertFalse($file->exists());
     }
     foreach ($archivesNotDeleted as $archive) {
         try {
             CMTest_TH::reinstantiateModel($archive);
             $this->assertTrue(true);
         } catch (CM_Exception_Nonexistent $ex) {
             $this->fail('Young streamchannelArchive deleted');
         }
     }
     foreach ($archivesDeleted as $archive) {
         try {
             CMTest_TH::reinstantiateModel($archive);
             $this->fail('Old streamchannelArchive not deleted');
         } catch (CM_Exception_Nonexistent $ex) {
             $this->assertTrue(true);
         }
     }
 }