示例#1
0
        public void CheckAudioDuration_SimpleMS()
        {
            ExternalAudioMedia audio = factory.Create <ExternalAudioMedia>();

            audio.ClipBegin = new Time(0);
            audio.ClipEnd   = new Time(1000);

            TimeDelta td = (TimeDelta)audio.Duration;

            Assert.AreEqual(1000, td.TimeDeltaAsMillisecondLong);
        }
示例#2
0
        public async Task TvShow()
        {
            var httpClient = HttpClientMockFactory.CreateClient(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(allTvShowProperties))
            });

            var search = new SearchApi("", httpClient);

            var result = await search.TvShowAsync("Game of thrones");

            result.ShouldNotBeNull();
            result.Results.ShouldNotBeNull();
            result.Results.Count.ShouldBe(allTvShowProperties.Results.Length);

            for (var index = 0; index < result.Results.Count; index++)
            {
                var tvShow         = result.Results[index];
                var expectedTvShow = MediaFactory.Create <TvShow>(
                    allTvShowProperties.Results[index]);

                tvShow.ShouldBe(expectedTvShow);
            }
        }
示例#3
0
        public async Task Movies()
        {
            var httpClient = HttpClientMockFactory.CreateClient(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(JsonConvert.SerializeObject(allMovieProperties))
            });

            var search = new SearchApi("", httpClient);

            var result = await search.MovieAsync("avengers");

            result.ShouldNotBeNull();
            result.Results.ShouldNotBeNull();
            result.Results.Count.ShouldBe(allMovieProperties.Results.Length);

            for (var index = 0; index < result.Results.Count; index++)
            {
                var movie         = result.Results[index];
                var expectedMovie = MediaFactory.Create <Movie>(
                    allMovieProperties.Results[index]);

                movie.ShouldBe(expectedMovie);
            }
        }
        public IList <IStorageLocation> CreateMedia
        (
            DicomMediaWriterParameters mediaParameters,
            ILocationProvider storageProvider,
            int[] frameList
        )
        {
            if (null == storageProvider)
            {
                throw new InvalidOperationException("No MediaStorage service found");
            }

            List <IStorageLocation> locations = new List <IStorageLocation> ( );
            var    dataset        = GetMediaDataset(mediaParameters.Dataset, mediaParameters.MediaInfo);
            string transferSyntax = (!string.IsNullOrWhiteSpace(mediaParameters.MediaInfo.TransferSyntax)) ? (mediaParameters.MediaInfo.TransferSyntax) : "";


            if (!StoreMultiFrames)
            {
                throw new InvalidOperationException("Media writer doesn't support generating frames");
            }

            foreach (int frame in frameList)
            {
                var storeLocation = storageProvider.GetLocation(MediaFactory.Create(mediaParameters.Dataset, frame, MediaType, transferSyntax));


                Upload(mediaParameters.Dataset, frame, storeLocation);

                locations.Add(storeLocation);
            }

            return(locations);
        }
示例#5
0
        public virtual IEnumerable <ObjectRetrieveResult> FindSopInstances
        (
            IObjectId query,
            string mediaType,
            IEnumerable <string> transferSyntaxes,
            string defaultTransfer
        )
        {
            foreach (var transfer in transferSyntaxes)
            {
                string instanceTransfer = (transfer == AnyTransferSyntaxValue) ? defaultTransfer : transfer;

                var mediaProperties = new DicomMediaProperties(mediaType, instanceTransfer);
                var mediaID         = MediaFactory.Create(query, mediaProperties);
                var found           = false;

                foreach (IStorageLocation location in StorageService.EnumerateLocation(mediaID))
                {
                    found = true;

                    yield return(new ObjectRetrieveResult(location, transfer));
                }

                if (found)
                {
                    break;
                }
            }
        }
        public virtual IEnumerable <ObjectRetrieveResult> GetTransformedSopInstances
        (
            IObjectId query,
            string fromMediaType,
            string fromTransferSyntax,
            string toMediaType,
            string toTransferSyntax
        )
        {
            var fromMediaProp = new DicomMediaProperties(fromMediaType, fromTransferSyntax);
            var fromMediaID   = MediaFactory.Create(query, fromMediaProp);
            var frameList     = (null != query.Frame) ? new int[] { query.Frame.Value } : null;


            if (StorageService.Exists(fromMediaID))
            {
                foreach (IStorageLocation location in StorageService.EnumerateLocation(fromMediaID))
                {
                    fo.DicomFile defaultFile = fo.DicomFile.Open(location.GetReadStream( ));

                    foreach (var transformedLocation in  TransformDataset(defaultFile.Dataset, toMediaType, toTransferSyntax, frameList))
                    {
                        yield return(new ObjectRetrieveResult(transformedLocation, toTransferSyntax));
                    }
                }
            }
        }
示例#7
0
        public virtual bool ObjetInstanceExist(IObjectId objectId, string mediaType, string transferSyntax)
        {
            var mediaProperties = new DicomMediaProperties(mediaType, transferSyntax);
            var mediaID         = MediaFactory.Create(objectId, mediaProperties);


            return(StorageService.Exists(mediaID));
        }
        private IMediaId GetFromMediaId(IObjectId query, string fromMediaType, string fromTransferSyntax)
        {
            DicomDataset ds = new DicomDataset();

            ds.Add(DicomTag.StudyInstanceUID, query.StudyInstanceUID);
            ds.Add(DicomTag.SeriesInstanceUID, query.SeriesInstanceUID);
            ds.Add(DicomTag.SOPInstanceUID, query.SOPInstanceUID);

            return(MediaFactory.Create(ds, 1, fromMediaType, fromTransferSyntax));
        }
示例#9
0
        protected override WadoResponse DoProcess(IWadoUriRequest request, string mimeType)
        {
            var dcmLocation = MediaStorage.GetLocation(MediaFactory.Create(request, new DicomMediaProperties {
                MediaType      = MimeMediaTypes.DICOM,
                TransferSyntax = (request.ImageRequestInfo != null) ? request.ImageRequestInfo.TransferSyntax : ""
            }));

            if (!dcmLocation.Exists( ))
            {
                throw new ApplicationException("Object Not Found - return proper wado error ");
            }

            //if (string.Compare(mimeType, MimeMediaTypes.DICOM, true) == 0)
            {
                return(new WadoResponse(Location.GetReadStream( ), mimeType));
            }
        }
示例#10
0
        public IList <IStorageLocation> CreateMedia
        (
            DicomMediaWriterParameters mediaParameters,
            ILocationProvider sotrageProvider
        )
        {
            if (null != sotrageProvider)
            {
                int framesCount = 1;
                List <IStorageLocation> locations = new List <IStorageLocation> ( );
                var    dataset        = GetMediaDataset(mediaParameters.Dataset, mediaParameters.MediaInfo);
                string transferSyntax = (!string.IsNullOrWhiteSpace(mediaParameters.MediaInfo.TransferSyntax)) ? (mediaParameters.MediaInfo.TransferSyntax) : "";

                if (StoreMultiFrames)
                {
                    DicomPixelData pd;


                    pd          = DicomPixelData.Create(mediaParameters.Dataset);
                    framesCount = pd.NumberOfFrames;
                }

                for (int frame = 1; frame <= framesCount; frame++)
                {
                    var storeLocation = sotrageProvider.GetLocation(MediaFactory.Create(mediaParameters.Dataset, frame, MediaType, transferSyntax));


                    Upload(dataset, frame, storeLocation);

                    locations.Add(storeLocation);
                }

                return(locations);
            }

            throw new InvalidOperationException("No MediaStorage service found");
        }
示例#11
0
 public virtual IEnumerable <IStorageLocation> RetrieveSopInstances(IObjectId query, DicomMediaProperties mediaInfo)
 {
     return(StorageService.EnumerateLocation(MediaFactory.Create(query, mediaInfo)));
 }
示例#12
0
 public virtual IStorageLocation RetrieveSopInstance(IObjectId query, DicomMediaProperties mediaInfo)
 {
     return(StorageService.GetLocation(MediaFactory.Create(query, mediaInfo)));
 }