Compare commits

..

31 Commits

Author SHA1 Message Date
Joshua M. Boniface 973fcdbaa1 Bump version to 10.6.2 2020-08-02 20:53:04 -04:00
dkanada 5ea5b9a654 Merge pull request #3795 from anthonylavado/master
Update to newer Jellyfin.XMLTV

(cherry picked from commit 714a6f04ef)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:50:44 -04:00
dkanada e657781459 Merge pull request #3792 from cvium/fix_tmdb_deserialize
TMDb: Change Budget and Revenue to long to avoid overflow
(cherry picked from commit 254ef6bc0d)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:50:44 -04:00
Bond-009 4e6e310b71 Merge pull request #3790 from cvium/fewer_string_allocs
Remove some unnecessary string allocations

(cherry picked from commit 43fa983414)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:50:44 -04:00
Joshua M. Boniface 43ade73be4 Merge pull request #3761 from cvium/fix_mem_leak
Fix DI memory leak

(cherry picked from commit 9bf6222597)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:37:11 -04:00
Anthony Lavado f88e9b2678 Merge pull request #3760 from thornbill/true-or-false
Fix inverted logic for LAN IP detection

(cherry picked from commit 4bad529fcb)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:37:11 -04:00
Bond-009 0eb0b15b2a Merge pull request #3757 from jellyfin/update_blurhashsharp
Update BlurHashSharp and set max size to 128x128

(cherry picked from commit ee3fae497c)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:37:11 -04:00
Joshua M. Boniface 7402679a99 Merge pull request #3728 from jellyfin/qsv-cutter
Adjust priority in outputSizeParam cutter

(cherry picked from commit 47e63def20)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:37:11 -04:00
Anthony Lavado e276532f2f Merge pull request #3727 from K900/patch-1
Fix #3624

(cherry picked from commit 06db5f8bca)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:37:01 -04:00
Joshua M. Boniface b1250e2e83 Merge pull request #3725 from joshuaboniface/fix-ci-docker
Flip quoting in variable set command

(cherry picked from commit 8c1dab146c)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:35:31 -04:00
Anthony Lavado 35d3ad1a55 Merge pull request #3723 from joshuaboniface/fix-ci-docker
Get and tag with the actual release version in CI

(cherry picked from commit b207907e1b)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:35:31 -04:00
Joshua M. Boniface 02f36373c2 Merge pull request #3720 from joshuaboniface/fix-bump-version
Fix bump_version so it works properly

(cherry picked from commit dc0f1788f4)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-08-02 20:35:31 -04:00
Joshua M. Boniface 3b73e74ce5 Bump version to 10.6.1 2020-07-27 18:59:16 -04:00
Anthony Lavado 8bb03e8f91 Merge pull request #3711 from yrjyrj123/fix_hw_decoder_for_macos
Fix the problem that hardware decoding cannot be used on macOS.

(cherry picked from commit ea0489a98e)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Anthony Lavado 3e742e99a5 Merge pull request #3704 from oddstr13/pr-dotdir-sample-1
Don't ignore dot directories or movies/episodes with sample in their name.

(cherry picked from commit 6eb3e736c6)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
dkanada ad3a96267e Merge pull request #3703 from oddstr13/pr-username-space-1
Allow space in username

(cherry picked from commit 8ab800508b)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Anthony Lavado 8b42ef451c Merge pull request #3699 from oddstr13/pr-embedded-subs-1
Fix embedded subtitles

(cherry picked from commit bfecfab538)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Joshua M. Boniface 4ce16489a4 Merge pull request #3675 from ferferga/fix-typo
Fix typo in debian config file

(cherry picked from commit 1a9adf283a)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 809651ceaf Merge pull request #3663 from crobibero/efcore-leak
Add missing usings to UserManager

(cherry picked from commit 6b11cccb7f)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Anthony Lavado 6547ae46ce Merge pull request #3660 from crobibero/plugin-config-location
Force plugin config location

(cherry picked from commit 468a7fea4c)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 cbf6ef4dbd Merge pull request #3649 from thornbill/fix-epg-update-maybe
Skip image processing for live tv sources

(cherry picked from commit e9758bde2a)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 e4ce72e7bb Merge pull request #3642 from crobibero/plugin-repo-x2
Try adding plugin repository again

(cherry picked from commit a86d8d1757)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Anthony Lavado 3b758c3a66 Merge pull request #3634 from crobibero/plugin-config
fix built in plugin js

(cherry picked from commit f23e119a68)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 dadd42e574 Merge pull request #3620 from BaronGreenback/IPFix
Fix for #3607 and #3515

(cherry picked from commit 0750357916)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
dkanada 349b789492 Merge pull request #3616 from crobibero/migration-new-install
Allow migration to optionally run on fresh install

(cherry picked from commit 107cf21f26)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 0ee0aa8941 Merge pull request #3615 from jellyfin/qsv-comet-lake
Fix QSV device creation on Comet Lake

(cherry picked from commit 6de6583cbd)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 94dbdd9f98 Merge pull request #3604 from joshuaboniface/fix-bad-deps
Fix bad Debuntu dependencies

(cherry picked from commit 41c4cfe0af)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 9875f30836 Merge pull request #3602 from crobibero/user-change-case
Fix username case change

(cherry picked from commit 8f11e057a2)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Anthony Lavado a717a531bc Merge pull request #3576 from HelloWorld017/fix/sami-utf16
Fix SAMI UTF-16 Encoding Bug

(cherry picked from commit 0cb2cd9456)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 d04e255a79 Merge pull request #3552 from BaronGreenback/NotificationFix
Fixes #3551 (Notifications Serialization error)

(cherry picked from commit 944fdb4c62)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
Bond-009 2fd902f1b2 Merge pull request #3521 from sachk/master
Fix support for mixed-protocol subtitles

(cherry picked from commit 323fc576a5)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
2020-07-27 18:53:09 -04:00
1567 changed files with 58776 additions and 71834 deletions
+13 -17
View File
@@ -7,17 +7,15 @@ parameters:
default: "ubuntu-latest" default: "ubuntu-latest"
- name: DotNetSdkVersion - name: DotNetSdkVersion
type: string type: string
default: 5.0.103 default: 3.1.100
jobs: jobs:
- job: CompatibilityCheck - job: CompatibilityCheck
displayName: Compatibility Check displayName: Compatibility Check
dependsOn: Build
condition: and(succeeded(), variables['System.PullRequest.PullRequestNumber'])
pool: pool:
vmImage: "${{ parameters.LinuxImage }}" vmImage: "${{ parameters.LinuxImage }}"
# only execute for pull requests
condition: and(succeeded(), variables['System.PullRequest.PullRequestNumber'])
strategy: strategy:
matrix: matrix:
${{ each Package in parameters.Packages }}: ${{ each Package in parameters.Packages }}:
@@ -25,7 +23,7 @@ jobs:
NugetPackageName: ${{ Package.value.NugetPackageName }} NugetPackageName: ${{ Package.value.NugetPackageName }}
AssemblyFileName: ${{ Package.value.AssemblyFileName }} AssemblyFileName: ${{ Package.value.AssemblyFileName }}
maxParallel: 2 maxParallel: 2
dependsOn: Build
steps: steps:
- checkout: none - checkout: none
@@ -36,33 +34,32 @@ jobs:
version: ${{ parameters.DotNetSdkVersion }} version: ${{ parameters.DotNetSdkVersion }}
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: 'Install ABI CompatibilityChecker Tool' displayName: 'Install ABI CompatibilityChecker tool'
inputs: inputs:
command: custom command: custom
custom: tool custom: tool
arguments: 'update compatibilitychecker -g' arguments: 'update compatibilitychecker -g'
- task: DownloadPipelineArtifact@2 - task: DownloadPipelineArtifact@2
displayName: 'Download New Assembly Build Artifact' displayName: "Download New Assembly Build Artifact"
inputs: inputs:
source: 'current' source: "current"
artifact: "$(NugetPackageName)" artifact: "$(NugetPackageName)"
path: "$(System.ArtifactsDirectory)/new-artifacts" path: "$(System.ArtifactsDirectory)/new-artifacts"
runVersion: "latest" runVersion: "latest"
- task: CopyFiles@2 - task: CopyFiles@2
displayName: 'Copy New Assembly Build Artifact' displayName: "Copy New Assembly Build Artifact"
inputs: inputs:
sourceFolder: $(System.ArtifactsDirectory)/new-artifacts sourceFolder: $(System.ArtifactsDirectory)/new-artifacts
contents: '**/*.dll' contents: "**/*.dll"
targetFolder: $(System.ArtifactsDirectory)/new-release targetFolder: $(System.ArtifactsDirectory)/new-release
cleanTargetFolder: true cleanTargetFolder: true
overWrite: true overWrite: true
flattenFolders: true flattenFolders: true
- task: DownloadPipelineArtifact@2 - task: DownloadPipelineArtifact@2
displayName: 'Download Reference Assembly Build Artifact' displayName: "Download Reference Assembly Build Artifact"
enabled: false
inputs: inputs:
source: "specific" source: "specific"
artifact: "$(NugetPackageName)" artifact: "$(NugetPackageName)"
@@ -73,19 +70,18 @@ jobs:
runBranch: "refs/heads/$(System.PullRequest.TargetBranch)" runBranch: "refs/heads/$(System.PullRequest.TargetBranch)"
- task: CopyFiles@2 - task: CopyFiles@2
displayName: 'Copy Reference Assembly Build Artifact' displayName: "Copy Reference Assembly Build Artifact"
enabled: false
inputs: inputs:
sourceFolder: $(System.ArtifactsDirectory)/current-artifacts sourceFolder: $(System.ArtifactsDirectory)/current-artifacts
contents: '**/*.dll' contents: "**/*.dll"
targetFolder: $(System.ArtifactsDirectory)/current-release targetFolder: $(System.ArtifactsDirectory)/current-release
cleanTargetFolder: true cleanTargetFolder: true
overWrite: true overWrite: true
flattenFolders: true flattenFolders: true
# The `--warnings-only` switch will swallow the return code and not emit any errors.
- task: DotNetCoreCLI@2 - task: DotNetCoreCLI@2
displayName: 'Execute ABI Compatibility Check Tool' displayName: 'Execute ABI Compatibility Check Tool'
enabled: false
inputs: inputs:
command: custom command: custom
custom: compat custom: compat
-59
View File
@@ -1,59 +0,0 @@
parameters:
- name: LinuxImage
type: string
default: "ubuntu-latest"
- name: GeneratorVersion
type: string
default: "5.0.1"
jobs:
- job: GenerateApiClients
displayName: 'Generate Api Clients'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
dependsOn: Test
pool:
vmImage: "${{ parameters.LinuxImage }}"
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download OpenAPI Spec Artifact'
inputs:
source: 'current'
artifact: "OpenAPI Spec"
path: "$(System.ArtifactsDirectory)/openapispec"
runVersion: "latest"
- task: CmdLine@2
displayName: 'Download OpenApi Generator'
inputs:
script: "wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${{ parameters.GeneratorVersion }}/openapi-generator-cli-${{ parameters.GeneratorVersion }}.jar -O openapi-generator-cli.jar"
## Authenticate with npm registry
- task: npmAuthenticate@0
inputs:
workingFile: ./.npmrc
customEndpoint: 'jellyfin-bot for NPM'
## Generate npm api client
- task: CmdLine@2
displayName: 'Build stable typescript axios client'
inputs:
script: "bash ./apiclient/templates/typescript/axios/generate.sh $(System.ArtifactsDirectory)"
## Run npm install
- task: Npm@1
displayName: 'Install npm dependencies'
inputs:
command: install
workingDir: ./apiclient/generated/typescript/axios
## Publish npm packages
- task: Npm@1
displayName: 'Publish stable typescript axios client'
inputs:
command: custom
customCommand: publish --access public
publishRegistry: useExternalRegistry
publishEndpoint: 'jellyfin-bot for NPM'
workingDir: ./apiclient/generated/typescript/axios
+5 -5
View File
@@ -1,7 +1,7 @@
parameters: parameters:
LinuxImage: 'ubuntu-latest' LinuxImage: 'ubuntu-latest'
RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj' RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj'
DotNetSdkVersion: 5.0.103 DotNetSdkVersion: 3.1.100
jobs: jobs:
- job: Build - job: Build
@@ -64,28 +64,28 @@ jobs:
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)' arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: false zipAfterPublish: false
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@0
displayName: 'Publish Artifact Naming' displayName: 'Publish Artifact Naming'
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release')) condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
inputs: inputs:
targetPath: '$(build.ArtifactStagingDirectory)/Jellyfin.Server/Emby.Naming.dll' targetPath: '$(build.ArtifactStagingDirectory)/Jellyfin.Server/Emby.Naming.dll'
artifactName: 'Jellyfin.Naming' artifactName: 'Jellyfin.Naming'
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@0
displayName: 'Publish Artifact Controller' displayName: 'Publish Artifact Controller'
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release')) condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
inputs: inputs:
targetPath: '$(build.ArtifactStagingDirectory)/Jellyfin.Server/MediaBrowser.Controller.dll' targetPath: '$(build.ArtifactStagingDirectory)/Jellyfin.Server/MediaBrowser.Controller.dll'
artifactName: 'Jellyfin.Controller' artifactName: 'Jellyfin.Controller'
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@0
displayName: 'Publish Artifact Model' displayName: 'Publish Artifact Model'
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release')) condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
inputs: inputs:
targetPath: '$(build.ArtifactStagingDirectory)/Jellyfin.Server/MediaBrowser.Model.dll' targetPath: '$(build.ArtifactStagingDirectory)/Jellyfin.Server/MediaBrowser.Model.dll'
artifactName: 'Jellyfin.Model' artifactName: 'Jellyfin.Model'
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@0
displayName: 'Publish Artifact Common' displayName: 'Publish Artifact Common'
condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release')) condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
inputs: inputs:
+23 -111
View File
@@ -22,12 +22,6 @@ jobs:
BuildConfiguration: ubuntu.armhf BuildConfiguration: ubuntu.armhf
Linux.amd64: Linux.amd64:
BuildConfiguration: linux.amd64 BuildConfiguration: linux.amd64
Linux.amd64-musl:
BuildConfiguration: linux.amd64-musl
Linux.arm64:
BuildConfiguration: linux.arm64
Linux.armhf:
BuildConfiguration: linux.armhf
Windows.amd64: Windows.amd64:
BuildConfiguration: windows.amd64 BuildConfiguration: windows.amd64
MacOS: MacOS:
@@ -48,7 +42,7 @@ jobs:
- script: 'docker image ls -a && docker run -v $(pwd)/deployment/dist:/dist -v $(pwd):/jellyfin -e IS_UNSTABLE="no" -e BUILD_ID=$(Build.BuildNumber) jellyfin-server-$(BuildConfiguration)' - script: 'docker image ls -a && docker run -v $(pwd)/deployment/dist:/dist -v $(pwd):/jellyfin -e IS_UNSTABLE="no" -e BUILD_ID=$(Build.BuildNumber) jellyfin-server-$(BuildConfiguration)'
displayName: 'Run Dockerfile (stable)' displayName: 'Run Dockerfile (stable)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v') condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
- task: PublishPipelineArtifact@1 - task: PublishPipelineArtifact@1
displayName: 'Publish Release' displayName: 'Publish Release'
@@ -71,38 +65,6 @@ jobs:
contents: '**' contents: '**'
targetFolder: '/srv/repository/incoming/azure/$(Build.BuildNumber)/$(BuildConfiguration)' targetFolder: '/srv/repository/incoming/azure/$(Build.BuildNumber)/$(BuildConfiguration)'
- job: OpenAPISpec
dependsOn: Test
condition: or(startsWith(variables['Build.SourceBranch'], 'refs/heads/master'),startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
displayName: 'Push OpenAPI Spec to repository'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download OpenAPI Spec'
inputs:
source: 'current'
artifact: "OpenAPI Spec"
path: "$(System.ArtifactsDirectory)/openapispec"
runVersion: "latest"
- task: SSH@0
displayName: 'Create target directory on repository server'
inputs:
sshEndpoint: repository
runOptions: 'inline'
inline: 'mkdir -p /srv/repository/incoming/azure/$(Build.BuildNumber)'
- task: CopyFilesOverSSH@0
displayName: 'Upload artifacts to repository server'
inputs:
sshEndpoint: repository
sourceFolder: '$(System.ArtifactsDirectory)/openapispec'
contents: 'openapi.json'
targetFolder: '/srv/repository/incoming/azure/$(Build.BuildNumber)'
- job: BuildDocker - job: BuildDocker
displayName: 'Build Docker' displayName: 'Build Docker'
@@ -125,7 +87,7 @@ jobs:
steps: steps:
- script: echo "##vso[task.setvariable variable=JellyfinVersion]$( awk -F '/' '{ print $NF }' <<<'$(Build.SourceBranch)' | sed 's/^v//' )" - script: echo "##vso[task.setvariable variable=JellyfinVersion]$( awk -F '/' '{ print $NF }' <<<'$(Build.SourceBranch)' | sed 's/^v//' )"
displayName: Set release version (stable) displayName: Set release version (stable)
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v') condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
- task: Docker@2 - task: Docker@2
displayName: 'Push Unstable Image' displayName: 'Push Unstable Image'
@@ -142,7 +104,7 @@ jobs:
- task: Docker@2 - task: Docker@2
displayName: 'Push Stable Image' displayName: 'Push Stable Image'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v') condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
inputs: inputs:
repository: 'jellyfin/jellyfin-server' repository: 'jellyfin/jellyfin-server'
command: buildAndPush command: buildAndPush
@@ -154,12 +116,11 @@ jobs:
$(JellyfinVersion)-$(BuildConfiguration) $(JellyfinVersion)-$(BuildConfiguration)
- job: CollectArtifacts - job: CollectArtifacts
timeoutInMinutes: 20
displayName: 'Collect Artifacts' displayName: 'Collect Artifacts'
continueOnError: true
dependsOn: dependsOn:
- BuildPackage - BuildPackage
- BuildDocker - BuildDocker
condition: and(succeeded('BuildPackage'), succeeded('BuildDocker'))
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
@@ -167,93 +128,44 @@ jobs:
steps: steps:
- task: SSH@0 - task: SSH@0
displayName: 'Update Unstable Repository' displayName: 'Update Unstable Repository'
continueOnError: true
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master') condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
inputs: inputs:
sshEndpoint: repository sshEndpoint: repository
runOptions: 'commands' runOptions: 'inline'
commands: nohup sudo /srv/repository/collect-server.azure.sh /srv/repository/incoming/azure $(Build.BuildNumber) unstable & inline: |
sudo /srv/repository/collect-server.azure.sh /srv/repository/incoming/azure $(Build.BuildNumber) unstable
rm $0
exit
- task: SSH@0 - task: SSH@0
displayName: 'Update Stable Repository' displayName: 'Update Stable Repository'
continueOnError: true condition: startsWith(variables['Build.SourceBranch'], 'refs/tags')
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
inputs: inputs:
sshEndpoint: repository sshEndpoint: repository
runOptions: 'commands' runOptions: 'inline'
commands: nohup sudo /srv/repository/collect-server.azure.sh /srv/repository/incoming/azure $(Build.BuildNumber) & inline: |
sudo /srv/repository/collect-server.azure.sh /srv/repository/incoming/azure $(Build.BuildNumber)
rm $0
exit
- job: PublishNuget - job: PublishNuget
displayName: 'Publish NuGet packages' displayName: 'Publish NuGet packages'
dependsOn:
- BuildPackage
condition: and(succeeded('BuildPackage'), startsWith(variables['Build.SourceBranch'], 'refs/tags'))
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
variables:
- name: JellyfinVersion
value: $[replace(variables['Build.SourceBranch'],'refs/tags/v','')]
steps: steps:
- task: UseDotNet@2 - task: NuGetCommand@2
displayName: 'Use .NET 5.0 sdk'
inputs: inputs:
packageType: 'sdk' command: 'pack'
version: '5.0.x' packagesToPack: Jellyfin.Data/Jellyfin.Data.csproj;MediaBrowser.Common/MediaBrowser.Common.csproj;MediaBrowser.Controller/MediaBrowser.Controller.csproj;MediaBrowser.Model/MediaBrowser.Model.csproj;Emby.Naming/Emby.Naming.csproj
packDestination: '$(Build.ArtifactStagingDirectory)'
- task: DotNetCoreCLI@2
displayName: 'Build Stable Nuget packages'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
inputs:
command: 'custom'
projects: |
Jellyfin.Data/Jellyfin.Data.csproj
MediaBrowser.Common/MediaBrowser.Common.csproj
MediaBrowser.Controller/MediaBrowser.Controller.csproj
MediaBrowser.Model/MediaBrowser.Model.csproj
Emby.Naming/Emby.Naming.csproj
custom: 'pack'
arguments: -o $(Build.ArtifactStagingDirectory) -p:Version=$(JellyfinVersion)
- task: DotNetCoreCLI@2
displayName: 'Build Unstable Nuget packages'
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: 'custom'
projects: |
Jellyfin.Data/Jellyfin.Data.csproj
MediaBrowser.Common/MediaBrowser.Common.csproj
MediaBrowser.Controller/MediaBrowser.Controller.csproj
MediaBrowser.Model/MediaBrowser.Model.csproj
Emby.Naming/Emby.Naming.csproj
custom: 'pack'
arguments: '--version-suffix $(Build.BuildNumber) -o $(Build.ArtifactStagingDirectory) -p:Stability=Unstable'
- task: PublishBuildArtifacts@1
displayName: 'Publish Nuget packages'
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)
artifactName: Jellyfin Nuget Packages
- task: NuGetCommand@2 - task: NuGetCommand@2
displayName: 'Push Nuget packages to stable feed'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
inputs: inputs:
command: 'push' command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg' packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
nuGetFeedType: 'external' includeNugetOrg: 'true'
publishFeedCredentials: 'NugetOrg'
allowPackageConflicts: true # This ignores an error if the version already exists
- task: NuGetAuthenticate@0
displayName: 'Authenticate to unstable Nuget feed'
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
- task: NuGetCommand@2
displayName: 'Push Nuget packages to unstable feed'
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' # No symbols since Azure Artifact does not support it
nuGetFeedType: 'internal'
publishVstsFeed: '7cce6c46-d610-45e3-9fb7-65a6bfd1b671/a5746b79-f369-42db-93ff-59cd066f9327'
allowPackageConflicts: true # This ignores an error if the version already exists
+6 -11
View File
@@ -10,7 +10,7 @@ parameters:
default: "tests/**/*Tests.csproj" default: "tests/**/*Tests.csproj"
- name: DotNetSdkVersion - name: DotNetSdkVersion
type: string type: string
default: 5.0.103 default: 3.1.100
jobs: jobs:
- job: Test - job: Test
@@ -30,11 +30,11 @@ jobs:
# This is required for the SonarCloud analyzer # This is required for the SonarCloud analyzer
- task: UseDotNet@2 - task: UseDotNet@2
displayName: "Install .NET SDK 5.x" displayName: "Install .NET Core SDK 2.1"
condition: eq(variables['ImageName'], 'ubuntu-latest') condition: eq(variables['ImageName'], 'ubuntu-latest')
inputs: inputs:
packageType: sdk packageType: sdk
version: '5.x' version: '2.1.805'
- task: UseDotNet@2 - task: UseDotNet@2
displayName: "Update DotNet" displayName: "Update DotNet"
@@ -56,7 +56,7 @@ jobs:
inputs: inputs:
command: "test" command: "test"
projects: ${{ parameters.TestProjects }} projects: ${{ parameters.TestProjects }}
arguments: '--configuration Release --collect:"XPlat Code Coverage" --settings tests/coverletArgs.runsettings --verbosity minimal' arguments: '--configuration Release --collect:"XPlat Code Coverage" --settings tests/coverletArgs.runsettings --verbosity minimal "-p:GenerateDocumentationFile=False"'
publishTestResults: true publishTestResults: true
testRunTitle: $(Agent.JobName) testRunTitle: $(Agent.JobName)
workingDirectory: "$(Build.SourcesDirectory)" workingDirectory: "$(Build.SourcesDirectory)"
@@ -74,6 +74,7 @@ jobs:
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4 - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging
displayName: 'Run ReportGenerator' displayName: 'Run ReportGenerator'
enabled: false
inputs: inputs:
reports: "$(Agent.TempDirectory)/**/coverage.cobertura.xml" reports: "$(Agent.TempDirectory)/**/coverage.cobertura.xml"
targetdir: "$(Agent.TempDirectory)/merged/" targetdir: "$(Agent.TempDirectory)/merged/"
@@ -83,16 +84,10 @@ jobs:
- task: PublishCodeCoverageResults@1 - task: PublishCodeCoverageResults@1
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) # !! THIS is for V1 only V2 will/should support merging
displayName: 'Publish Code Coverage' displayName: 'Publish Code Coverage'
enabled: false
inputs: inputs:
codeCoverageTool: "cobertura" codeCoverageTool: "cobertura"
#summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' # !!THIS IS FOR V2 #summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml' # !!THIS IS FOR V2
summaryFileLocation: "$(Agent.TempDirectory)/merged/**.xml" summaryFileLocation: "$(Agent.TempDirectory)/merged/**.xml"
pathToSources: $(Build.SourcesDirectory) pathToSources: $(Build.SourcesDirectory)
failIfCoverageEmpty: true failIfCoverageEmpty: true
- task: PublishPipelineArtifact@1
displayName: 'Publish OpenAPI Artifact'
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
inputs:
targetPath: "tests/Jellyfin.Api.Tests/bin/Release/net5.0/openapi.json"
artifactName: 'OpenAPI Spec'
+5 -20
View File
@@ -6,28 +6,22 @@ variables:
- name: RestoreBuildProjects - name: RestoreBuildProjects
value: 'Jellyfin.Server/Jellyfin.Server.csproj' value: 'Jellyfin.Server/Jellyfin.Server.csproj'
- name: DotNetSdkVersion - name: DotNetSdkVersion
value: 5.0.103 value: 3.1.100
pr: pr:
autoCancel: true autoCancel: true
trigger: trigger:
batch: true batch: true
branches:
include:
- '*'
tags:
include:
- 'v*'
jobs: jobs:
- ${{ if not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')) }}: - ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-main.yml - template: azure-pipelines-main.yml
parameters: parameters:
LinuxImage: 'ubuntu-latest' LinuxImage: 'ubuntu-latest'
RestoreBuildProjects: $(RestoreBuildProjects) RestoreBuildProjects: $(RestoreBuildProjects)
- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}: - ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-test.yml - template: azure-pipelines-test.yml
parameters: parameters:
ImageNames: ImageNames:
@@ -35,13 +29,7 @@ jobs:
Windows: 'windows-latest' Windows: 'windows-latest'
macOS: 'macos-latest' macOS: 'macos-latest'
- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}: - ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-test.yml
parameters:
ImageNames:
Linux: 'ubuntu-latest'
- ${{ if not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master'))) }}:
- template: azure-pipelines-abi.yml - template: azure-pipelines-abi.yml
parameters: parameters:
Packages: Packages:
@@ -59,8 +47,5 @@ jobs:
AssemblyFileName: MediaBrowser.Common.dll AssemblyFileName: MediaBrowser.Common.dll
LinuxImage: 'ubuntu-latest' LinuxImage: 'ubuntu-latest'
- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}: - ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
- template: azure-pipelines-package.yml - template: azure-pipelines-package.yml
- ${{ if or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/heads/master')) }}:
- template: azure-pipelines-api-client.yml
-36
View File
@@ -1,36 +0,0 @@
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '24 2 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
queries: +security-extended
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
-1
View File
@@ -276,4 +276,3 @@ BenchmarkDotNet.Artifacts
web/ web/
web-src.* web-src.*
MediaBrowser.WebDashboard/jellyfin-web MediaBrowser.WebDashboard/jellyfin-web
apiclient/generated
-3
View File
@@ -1,3 +0,0 @@
registry=https://registry.npmjs.org/
@jellyfin:registry=https://pkgs.dev.azure.com/jellyfin-project/jellyfin/_packaging/unstable/npm/registry/
always-auth=true
+3 -17
View File
@@ -6,25 +6,11 @@
"type": "coreclr", "type": "coreclr",
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net5.0/jellyfin.dll", // If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/netcoreapp3.1/jellyfin.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}/Jellyfin.Server", "cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole", // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"serverReadyAction": {
"action": "openExternally",
"pattern": "Overriding address\\(es\\) \\'(https?:\\S+)\\'",
}
},
{
"name": ".NET Core Launch (nowebclient)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net5.0/jellyfin.dll",
"args": ["--nowebclient"],
"cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole", "console": "internalConsole",
"stopAtEntry": false, "stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart" "internalConsoleOptions": "openOnSessionStart"
+1 -1
View File
@@ -17,7 +17,7 @@
"type": "process", "type": "process",
"args": [ "args": [
"test", "test",
"${workspaceFolder}/tests/Jellyfin.Api.Tests/Jellyfin.Api.Tests.csproj" "${workspaceFolder}/tests/MediaBrowser.Api.Tests/MediaBrowser.Api.Tests.csproj"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
} }
-13
View File
@@ -7,7 +7,6 @@
- [anthonylavado](https://github.com/anthonylavado) - [anthonylavado](https://github.com/anthonylavado)
- [Artiume](https://github.com/Artiume) - [Artiume](https://github.com/Artiume)
- [AThomsen](https://github.com/AThomsen) - [AThomsen](https://github.com/AThomsen)
- [barongreenback](https://github.com/BaronGreenback)
- [barronpm](https://github.com/barronpm) - [barronpm](https://github.com/barronpm)
- [bilde2910](https://github.com/bilde2910) - [bilde2910](https://github.com/bilde2910)
- [bfayers](https://github.com/bfayers) - [bfayers](https://github.com/bfayers)
@@ -17,7 +16,6 @@
- [bugfixin](https://github.com/bugfixin) - [bugfixin](https://github.com/bugfixin)
- [chaosinnovator](https://github.com/chaosinnovator) - [chaosinnovator](https://github.com/chaosinnovator)
- [ckcr4lyf](https://github.com/ckcr4lyf) - [ckcr4lyf](https://github.com/ckcr4lyf)
- [ConfusedPolarBear](https://github.com/ConfusedPolarBear)
- [crankdoofus](https://github.com/crankdoofus) - [crankdoofus](https://github.com/crankdoofus)
- [crobibero](https://github.com/crobibero) - [crobibero](https://github.com/crobibero)
- [cromefire](https://github.com/cromefire) - [cromefire](https://github.com/cromefire)
@@ -49,7 +47,6 @@
- [h1nk](https://github.com/h1nk) - [h1nk](https://github.com/h1nk)
- [hawken93](https://github.com/hawken93) - [hawken93](https://github.com/hawken93)
- [HelloWorld017](https://github.com/HelloWorld017) - [HelloWorld017](https://github.com/HelloWorld017)
- [ikomhoog](https://github.com/ikomhoog)
- [jftuga](https://github.com/jftuga) - [jftuga](https://github.com/jftuga)
- [joern-h](https://github.com/joern-h) - [joern-h](https://github.com/joern-h)
- [joshuaboniface](https://github.com/joshuaboniface) - [joshuaboniface](https://github.com/joshuaboniface)
@@ -59,7 +56,6 @@
- [Larvitar](https://github.com/Larvitar) - [Larvitar](https://github.com/Larvitar)
- [LeoVerto](https://github.com/LeoVerto) - [LeoVerto](https://github.com/LeoVerto)
- [Liggy](https://github.com/Liggy) - [Liggy](https://github.com/Liggy)
- [lmaonator](https://github.com/lmaonator)
- [LogicalPhallacy](https://github.com/LogicalPhallacy) - [LogicalPhallacy](https://github.com/LogicalPhallacy)
- [loli10K](https://github.com/loli10K) - [loli10K](https://github.com/loli10K)
- [lostmypillow](https://github.com/lostmypillow) - [lostmypillow](https://github.com/lostmypillow)
@@ -80,9 +76,7 @@
- [Nickbert7](https://github.com/Nickbert7) - [Nickbert7](https://github.com/Nickbert7)
- [nvllsvm](https://github.com/nvllsvm) - [nvllsvm](https://github.com/nvllsvm)
- [nyanmisaka](https://github.com/nyanmisaka) - [nyanmisaka](https://github.com/nyanmisaka)
- [OancaAndrei](https://github.com/OancaAndrei)
- [oddstr13](https://github.com/oddstr13) - [oddstr13](https://github.com/oddstr13)
- [orryverducci](https://github.com/orryverducci)
- [petermcneil](https://github.com/petermcneil) - [petermcneil](https://github.com/petermcneil)
- [Phlogi](https://github.com/Phlogi) - [Phlogi](https://github.com/Phlogi)
- [pjeanjean](https://github.com/pjeanjean) - [pjeanjean](https://github.com/pjeanjean)
@@ -104,11 +98,8 @@
- [shemanaev](https://github.com/shemanaev) - [shemanaev](https://github.com/shemanaev)
- [skaro13](https://github.com/skaro13) - [skaro13](https://github.com/skaro13)
- [sl1288](https://github.com/sl1288) - [sl1288](https://github.com/sl1288)
- [Smith00101010](https://github.com/Smith00101010)
- [sorinyo2004](https://github.com/sorinyo2004) - [sorinyo2004](https://github.com/sorinyo2004)
- [sparky8251](https://github.com/sparky8251) - [sparky8251](https://github.com/sparky8251)
- [spookbits](https://github.com/spookbits)
- [ssenart] (https://github.com/ssenart)
- [stanionascu](https://github.com/stanionascu) - [stanionascu](https://github.com/stanionascu)
- [stevehayles](https://github.com/stevehayles) - [stevehayles](https://github.com/stevehayles)
- [SuperSandro2000](https://github.com/SuperSandro2000) - [SuperSandro2000](https://github.com/SuperSandro2000)
@@ -141,9 +132,6 @@
- [YouKnowBlom](https://github.com/YouKnowBlom) - [YouKnowBlom](https://github.com/YouKnowBlom)
- [KristupasSavickas](https://github.com/KristupasSavickas) - [KristupasSavickas](https://github.com/KristupasSavickas)
- [Pusta](https://github.com/pusta) - [Pusta](https://github.com/pusta)
- [nielsvanvelzen](https://github.com/nielsvanvelzen)
- [skyfrk](https://github.com/skyfrk)
- [ianjazz246](https://github.com/ianjazz246)
# Emby Contributors # Emby Contributors
@@ -207,4 +195,3 @@
- [tikuf](https://github.com/tikuf/) - [tikuf](https://github.com/tikuf/)
- [Tim Hobbs](https://github.com/timhobbs) - [Tim Hobbs](https://github.com/timhobbs)
- [SvenVandenbrande](https://github.com/SvenVandenbrande) - [SvenVandenbrande](https://github.com/SvenVandenbrande)
- [olsh](https://github.com/olsh)
+4 -25
View File
@@ -1,4 +1,4 @@
ARG DOTNET_VERSION=5.0 ARG DOTNET_VERSION=3.1
FROM node:alpine as web-builder FROM node:alpine as web-builder
ARG JELLYFIN_WEB_VERSION=master ARG JELLYFIN_WEB_VERSION=master
@@ -8,13 +8,13 @@ RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-
&& yarn install \ && yarn install \
&& mv dist /dist && mv dist /dist
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-buster-slim as builder FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION}-buster as builder
WORKDIR /repo WORKDIR /repo
COPY . . COPY . .
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
# because of changes in docker and systemd we need to not build in parallel at the moment # because of changes in docker and systemd we need to not build in parallel at the moment
# see https://success.docker.com/article/how-to-reserve-resource-temporarily-unavailable-errors-due-to-tasksmax-setting # see https://success.docker.com/article/how-to-reserve-resource-temporarily-unavailable-errors-due-to-tasksmax-setting
RUN dotnet publish Jellyfin.Server --disable-parallel --configuration Release --output="/jellyfin" --self-contained --runtime linux-x64 "-p:DebugSymbols=false;DebugType=none" RUN dotnet publish Jellyfin.Server --disable-parallel --configuration Release --output="/jellyfin" --self-contained --runtime linux-x64 "-p:GenerateDocumentationFile=false;DebugSymbols=false;DebugType=none"
FROM debian:buster-slim FROM debian:buster-slim
@@ -27,15 +27,8 @@ ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
COPY --from=builder /jellyfin /jellyfin COPY --from=builder /jellyfin /jellyfin
COPY --from=web-builder /dist /jellyfin/jellyfin-web COPY --from=web-builder /dist /jellyfin/jellyfin-web
# https://github.com/intel/compute-runtime/releases
ARG GMMLIB_VERSION=20.3.2
ARG IGC_VERSION=1.0.5435
ARG NEO_VERSION=20.46.18421
ARG LEVEL_ZERO_VERSION=1.0.18421
# Install dependencies: # Install dependencies:
# mesa-va-drivers: needed for AMD VAAPI. Mesa >= 20.1 is required for HEVC transcoding. # mesa-va-drivers: needed for AMD VAAPI
RUN apt-get update \ RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y ca-certificates gnupg wget apt-transport-https \ && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates gnupg wget apt-transport-https \
&& wget -O - https://repo.jellyfin.org/jellyfin_team.gpg.key | apt-key add - \ && wget -O - https://repo.jellyfin.org/jellyfin_team.gpg.key | apt-key add - \
@@ -46,20 +39,6 @@ RUN apt-get update \
jellyfin-ffmpeg \ jellyfin-ffmpeg \
openssl \ openssl \
locales \ locales \
# Intel VAAPI Tone mapping dependencies:
# Prefer NEO to Beignet since the latter one doesn't support Comet Lake or newer for now.
# Do not use the intel-opencl-icd package from repo since they will not build with RELEASE_WITH_REGKEYS enabled.
&& mkdir intel-compute-runtime \
&& cd intel-compute-runtime \
&& wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-gmmlib_${GMMLIB_VERSION}_amd64.deb \
&& wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-${IGC_VERSION}/intel-igc-core_${IGC_VERSION}_amd64.deb \
&& wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-${IGC_VERSION}/intel-igc-opencl_${IGC_VERSION}_amd64.deb \
&& wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-opencl_${NEO_VERSION}_amd64.deb \
&& wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-ocloc_${NEO_VERSION}_amd64.deb \
&& wget https://github.com/intel/compute-runtime/releases/download/${NEO_VERSION}/intel-level-zero-gpu_${LEVEL_ZERO_VERSION}_amd64.deb \
&& dpkg -i *.deb \
&& cd .. \
&& rm -rf intel-compute-runtime \
&& apt-get remove gnupg wget apt-transport-https -y \ && apt-get remove gnupg wget apt-transport-https -y \
&& apt-get clean autoclean -y \ && apt-get clean autoclean -y \
&& apt-get autoremove -y \ && apt-get autoremove -y \
+3 -3
View File
@@ -2,7 +2,7 @@
##################################### #####################################
# Requires binfm_misc registration # Requires binfm_misc registration
# https://github.com/multiarch/qemu-user-static#binfmt_misc-register # https://github.com/multiarch/qemu-user-static#binfmt_misc-register
ARG DOTNET_VERSION=5.0 ARG DOTNET_VERSION=3.1
FROM node:alpine as web-builder FROM node:alpine as web-builder
@@ -14,14 +14,14 @@ RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-
&& mv dist /dist && mv dist /dist
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} as builder FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
WORKDIR /repo WORKDIR /repo
COPY . . COPY . .
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
# Discard objs - may cause failures if exists # Discard objs - may cause failures if exists
RUN find . -type d -name obj | xargs -r rm -r RUN find . -type d -name obj | xargs -r rm -r
# Build # Build
RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-arm "-p:DebugSymbols=false;DebugType=none" RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-arm "-p:GenerateDocumentationFile=false;DebugSymbols=false;DebugType=none"
FROM multiarch/qemu-user-static:x86_64-arm as qemu FROM multiarch/qemu-user-static:x86_64-arm as qemu
+3 -3
View File
@@ -2,7 +2,7 @@
##################################### #####################################
# Requires binfm_misc registration # Requires binfm_misc registration
# https://github.com/multiarch/qemu-user-static#binfmt_misc-register # https://github.com/multiarch/qemu-user-static#binfmt_misc-register
ARG DOTNET_VERSION=5.0 ARG DOTNET_VERSION=3.1
FROM node:alpine as web-builder FROM node:alpine as web-builder
@@ -14,14 +14,14 @@ RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-
&& mv dist /dist && mv dist /dist
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} as builder FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
WORKDIR /repo WORKDIR /repo
COPY . . COPY . .
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
# Discard objs - may cause failures if exists # Discard objs - may cause failures if exists
RUN find . -type d -name obj | xargs -r rm -r RUN find . -type d -name obj | xargs -r rm -r
# Build # Build
RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-arm64 "-p:DebugSymbols=false;DebugType=none" RUN dotnet publish Jellyfin.Server --configuration Release --output="/jellyfin" --self-contained --runtime linux-arm64 "-p:GenerateDocumentationFile=false;DebugSymbols=false;DebugType=none"
FROM multiarch/qemu-user-static:x86_64-aarch64 as qemu FROM multiarch/qemu-user-static:x86_64-aarch64 as qemu
FROM arm64v8/debian:buster-slim FROM arm64v8/debian:buster-slim
+1 -1
View File
@@ -10,7 +10,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+1 -1
View File
@@ -31,7 +31,7 @@ namespace DvdLib.Ifo
continue; continue;
} }
var nums = ifo.Name.Split('_', StringSplitOptions.RemoveEmptyEntries); var nums = ifo.Name.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
if (nums.Length >= 2 && ushort.TryParse(nums[1], out var ifoNumber)) if (nums.Length >= 2 && ushort.TryParse(nums[1], out var ifoNumber))
{ {
ReadVTS(ifoNumber, ifo.FullName); ReadVTS(ifoNumber, ifo.FullName);
+383
View File
@@ -0,0 +1,383 @@
#pragma warning disable CS1591
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Emby.Dlna.Main;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Services;
namespace Emby.Dlna.Api
{
[Route("/Dlna/{UuId}/description.xml", "GET", Summary = "Gets dlna server info")]
[Route("/Dlna/{UuId}/description", "GET", Summary = "Gets dlna server info")]
public class GetDescriptionXml
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/contentdirectory/contentdirectory.xml", "GET", Summary = "Gets dlna content directory xml")]
[Route("/Dlna/{UuId}/contentdirectory/contentdirectory", "GET", Summary = "Gets dlna content directory xml")]
public class GetContentDirectory
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/connectionmanager/connectionmanager.xml", "GET", Summary = "Gets dlna connection manager xml")]
[Route("/Dlna/{UuId}/connectionmanager/connectionmanager", "GET", Summary = "Gets dlna connection manager xml")]
public class GetConnnectionManager
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/mediareceiverregistrar/mediareceiverregistrar.xml", "GET", Summary = "Gets dlna mediareceiverregistrar xml")]
[Route("/Dlna/{UuId}/mediareceiverregistrar/mediareceiverregistrar", "GET", Summary = "Gets dlna mediareceiverregistrar xml")]
public class GetMediaReceiverRegistrar
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/contentdirectory/control", "POST", Summary = "Processes a control request")]
public class ProcessContentDirectoryControlRequest : IRequiresRequestStream
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
public Stream RequestStream { get; set; }
}
[Route("/Dlna/{UuId}/connectionmanager/control", "POST", Summary = "Processes a control request")]
public class ProcessConnectionManagerControlRequest : IRequiresRequestStream
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
public Stream RequestStream { get; set; }
}
[Route("/Dlna/{UuId}/mediareceiverregistrar/control", "POST", Summary = "Processes a control request")]
public class ProcessMediaReceiverRegistrarControlRequest : IRequiresRequestStream
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UuId { get; set; }
public Stream RequestStream { get; set; }
}
[Route("/Dlna/{UuId}/mediareceiverregistrar/events", "SUBSCRIBE", Summary = "Processes an event subscription request")]
[Route("/Dlna/{UuId}/mediareceiverregistrar/events", "UNSUBSCRIBE", Summary = "Processes an event subscription request")]
public class ProcessMediaReceiverRegistrarEventRequest
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "SUBSCRIBE,UNSUBSCRIBE")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/contentdirectory/events", "SUBSCRIBE", Summary = "Processes an event subscription request")]
[Route("/Dlna/{UuId}/contentdirectory/events", "UNSUBSCRIBE", Summary = "Processes an event subscription request")]
public class ProcessContentDirectoryEventRequest
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "SUBSCRIBE,UNSUBSCRIBE")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/connectionmanager/events", "SUBSCRIBE", Summary = "Processes an event subscription request")]
[Route("/Dlna/{UuId}/connectionmanager/events", "UNSUBSCRIBE", Summary = "Processes an event subscription request")]
public class ProcessConnectionManagerEventRequest
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "SUBSCRIBE,UNSUBSCRIBE")]
public string UuId { get; set; }
}
[Route("/Dlna/{UuId}/icons/{Filename}", "GET", Summary = "Gets a server icon")]
[Route("/Dlna/icons/{Filename}", "GET", Summary = "Gets a server icon")]
public class GetIcon
{
[ApiMember(Name = "UuId", Description = "Server UuId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string UuId { get; set; }
[ApiMember(Name = "Filename", Description = "The icon filename", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Filename { get; set; }
}
public class DlnaServerService : IService, IRequiresRequest
{
private const string XMLContentType = "text/xml; charset=UTF-8";
private readonly IDlnaManager _dlnaManager;
private readonly IHttpResultFactory _resultFactory;
private readonly IServerConfigurationManager _configurationManager;
public IRequest Request { get; set; }
private IContentDirectory ContentDirectory => DlnaEntryPoint.Current.ContentDirectory;
private IConnectionManager ConnectionManager => DlnaEntryPoint.Current.ConnectionManager;
private IMediaReceiverRegistrar MediaReceiverRegistrar => DlnaEntryPoint.Current.MediaReceiverRegistrar;
public DlnaServerService(
IDlnaManager dlnaManager,
IHttpResultFactory httpResultFactory,
IServerConfigurationManager configurationManager)
{
_dlnaManager = dlnaManager;
_resultFactory = httpResultFactory;
_configurationManager = configurationManager;
}
private string GetHeader(string name)
{
return Request.Headers[name];
}
public object Get(GetDescriptionXml request)
{
var url = Request.AbsoluteUri;
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, request.UuId, serverAddress);
var cacheLength = TimeSpan.FromDays(1);
var cacheKey = Request.RawUrl.GetMD5();
var bytes = Encoding.UTF8.GetBytes(xml);
return _resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, XMLContentType, () => Task.FromResult<Stream>(new MemoryStream(bytes)));
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Get(GetContentDirectory request)
{
var xml = ContentDirectory.GetServiceXml();
return _resultFactory.GetResult(Request, xml, XMLContentType);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Get(GetMediaReceiverRegistrar request)
{
var xml = MediaReceiverRegistrar.GetServiceXml();
return _resultFactory.GetResult(Request, xml, XMLContentType);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Get(GetConnnectionManager request)
{
var xml = ConnectionManager.GetServiceXml();
return _resultFactory.GetResult(Request, xml, XMLContentType);
}
public async Task<object> Post(ProcessMediaReceiverRegistrarControlRequest request)
{
var response = await PostAsync(request.RequestStream, MediaReceiverRegistrar).ConfigureAwait(false);
return _resultFactory.GetResult(Request, response.Xml, XMLContentType);
}
public async Task<object> Post(ProcessContentDirectoryControlRequest request)
{
var response = await PostAsync(request.RequestStream, ContentDirectory).ConfigureAwait(false);
return _resultFactory.GetResult(Request, response.Xml, XMLContentType);
}
public async Task<object> Post(ProcessConnectionManagerControlRequest request)
{
var response = await PostAsync(request.RequestStream, ConnectionManager).ConfigureAwait(false);
return _resultFactory.GetResult(Request, response.Xml, XMLContentType);
}
private Task<ControlResponse> PostAsync(Stream requestStream, IUpnpService service)
{
var id = GetPathValue(2).ToString();
return service.ProcessControlRequestAsync(new ControlRequest
{
Headers = Request.Headers,
InputXml = requestStream,
TargetServerUuId = id,
RequestedUrl = Request.AbsoluteUri
});
}
// Copied from MediaBrowser.Api/BaseApiService.cs
// TODO: Remove code duplication
/// <summary>
/// Gets the path segment at the specified index.
/// </summary>
/// <param name="index">The index of the path segment.</param>
/// <returns>The path segment at the specified index.</returns>
/// <exception cref="IndexOutOfRangeException" >Path doesn't contain enough segments.</exception>
/// <exception cref="InvalidDataException" >Path doesn't start with the base url.</exception>
protected internal ReadOnlySpan<char> GetPathValue(int index)
{
static void ThrowIndexOutOfRangeException()
=> throw new IndexOutOfRangeException("Path doesn't contain enough segments.");
static void ThrowInvalidDataException()
=> throw new InvalidDataException("Path doesn't start with the base url.");
ReadOnlySpan<char> path = Request.PathInfo;
// Remove the protocol part from the url
int pos = path.LastIndexOf("://");
if (pos != -1)
{
path = path.Slice(pos + 3);
}
// Remove the query string
pos = path.LastIndexOf('?');
if (pos != -1)
{
path = path.Slice(0, pos);
}
// Remove the domain
pos = path.IndexOf('/');
if (pos != -1)
{
path = path.Slice(pos);
}
// Remove base url
string baseUrl = _configurationManager.Configuration.BaseUrl;
int baseUrlLen = baseUrl.Length;
if (baseUrlLen != 0)
{
if (path.StartsWith(baseUrl, StringComparison.OrdinalIgnoreCase))
{
path = path.Slice(baseUrlLen);
}
else
{
// The path doesn't start with the base url,
// how did we get here?
ThrowInvalidDataException();
}
}
// Remove leading /
path = path.Slice(1);
// Backwards compatibility
const string Emby = "emby/";
if (path.StartsWith(Emby, StringComparison.OrdinalIgnoreCase))
{
path = path.Slice(Emby.Length);
}
const string MediaBrowser = "mediabrowser/";
if (path.StartsWith(MediaBrowser, StringComparison.OrdinalIgnoreCase))
{
path = path.Slice(MediaBrowser.Length);
}
// Skip segments until we are at the right index
for (int i = 0; i < index; i++)
{
pos = path.IndexOf('/');
if (pos == -1)
{
ThrowIndexOutOfRangeException();
}
path = path.Slice(pos + 1);
}
// Remove the rest
pos = path.IndexOf('/');
if (pos != -1)
{
path = path.Slice(0, pos);
}
return path;
}
public object Get(GetIcon request)
{
var contentType = "image/" + Path.GetExtension(request.Filename)
.TrimStart('.')
.ToLowerInvariant();
var cacheLength = TimeSpan.FromDays(365);
var cacheKey = Request.RawUrl.GetMD5();
return _resultFactory.GetStaticResult(Request, cacheKey, null, cacheLength, contentType, () => Task.FromResult(_dlnaManager.GetIcon(request.Filename).Stream));
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Subscribe(ProcessContentDirectoryEventRequest request)
{
return ProcessEventRequest(ContentDirectory);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Subscribe(ProcessConnectionManagerEventRequest request)
{
return ProcessEventRequest(ConnectionManager);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Subscribe(ProcessMediaReceiverRegistrarEventRequest request)
{
return ProcessEventRequest(MediaReceiverRegistrar);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Unsubscribe(ProcessContentDirectoryEventRequest request)
{
return ProcessEventRequest(ContentDirectory);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Unsubscribe(ProcessConnectionManagerEventRequest request)
{
return ProcessEventRequest(ConnectionManager);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Unsubscribe(ProcessMediaReceiverRegistrarEventRequest request)
{
return ProcessEventRequest(MediaReceiverRegistrar);
}
private object ProcessEventRequest(IEventManager eventManager)
{
var subscriptionId = GetHeader("SID");
if (string.Equals(Request.Verb, "SUBSCRIBE", StringComparison.OrdinalIgnoreCase))
{
var notificationType = GetHeader("NT");
var callback = GetHeader("CALLBACK");
var timeoutString = GetHeader("TIMEOUT");
if (string.IsNullOrEmpty(notificationType))
{
return GetSubscriptionResponse(eventManager.RenewEventSubscription(subscriptionId, notificationType, timeoutString, callback));
}
return GetSubscriptionResponse(eventManager.CreateEventSubscription(notificationType, timeoutString, callback));
}
return GetSubscriptionResponse(eventManager.CancelEventSubscription(subscriptionId));
}
private object GetSubscriptionResponse(EventSubscriptionResponse response)
{
return _resultFactory.GetResult(Request, response.Content, response.ContentType, response.Headers);
}
}
}
+88
View File
@@ -0,0 +1,88 @@
#pragma warning disable CS1591
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Services;
namespace Emby.Dlna.Api
{
[Route("/Dlna/ProfileInfos", "GET", Summary = "Gets a list of profiles")]
public class GetProfileInfos : IReturn<DeviceProfileInfo[]>
{
}
[Route("/Dlna/Profiles/{Id}", "DELETE", Summary = "Deletes a profile")]
public class DeleteProfile : IReturnVoid
{
[ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
public string Id { get; set; }
}
[Route("/Dlna/Profiles/Default", "GET", Summary = "Gets the default profile")]
public class GetDefaultProfile : IReturn<DeviceProfile>
{
}
[Route("/Dlna/Profiles/{Id}", "GET", Summary = "Gets a single profile")]
public class GetProfile : IReturn<DeviceProfile>
{
[ApiMember(Name = "Id", Description = "Profile Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Id { get; set; }
}
[Route("/Dlna/Profiles/{Id}", "POST", Summary = "Updates a profile")]
public class UpdateProfile : DeviceProfile, IReturnVoid
{
}
[Route("/Dlna/Profiles", "POST", Summary = "Creates a profile")]
public class CreateProfile : DeviceProfile, IReturnVoid
{
}
[Authenticated(Roles = "Admin")]
public class DlnaService : IService
{
private readonly IDlnaManager _dlnaManager;
public DlnaService(IDlnaManager dlnaManager)
{
_dlnaManager = dlnaManager;
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Get(GetProfileInfos request)
{
return _dlnaManager.GetProfileInfos().ToArray();
}
public object Get(GetProfile request)
{
return _dlnaManager.GetProfile(request.Id);
}
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "request", Justification = "Required for ServiceStack")]
public object Get(GetDefaultProfile request)
{
return _dlnaManager.GetDefaultProfile();
}
public void Delete(DeleteProfile request)
{
_dlnaManager.DeleteProfile(request.Id);
}
public void Post(UpdateProfile request)
{
_dlnaManager.UpdateProfile(request);
}
public void Post(CreateProfile request)
{
_dlnaManager.CreateProfile(request);
}
}
}
+5 -15
View File
@@ -1,23 +1,13 @@
#pragma warning disable CS1591
namespace Emby.Dlna.Common namespace Emby.Dlna.Common
{ {
/// <summary>
/// DLNA Query parameter type, used when querying DLNA devices via SOAP.
/// </summary>
public class Argument public class Argument
{ {
/// <summary> public string Name { get; set; }
/// Gets or sets name of the DLNA argument.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary> public string Direction { get; set; }
/// Gets or sets the direction of the parameter.
/// </summary>
public string Direction { get; set; } = string.Empty;
/// <summary> public string RelatedStateVariable { get; set; }
/// Gets or sets the related DLNA state variable for this argument.
/// </summary>
public string RelatedStateVariable { get; set; } = string.Empty;
} }
} }
+10 -22
View File
@@ -1,41 +1,29 @@
#pragma warning disable CS1591
using System.Globalization; using System.Globalization;
namespace Emby.Dlna.Common namespace Emby.Dlna.Common
{ {
/// <summary>
/// Defines the <see cref="DeviceIcon" />.
/// </summary>
public class DeviceIcon public class DeviceIcon
{ {
/// <summary> public string Url { get; set; }
/// Gets or sets the Url.
/// </summary>
public string Url { get; set; } = string.Empty;
/// <summary> public string MimeType { get; set; }
/// Gets or sets the MimeType.
/// </summary>
public string MimeType { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the Width.
/// </summary>
public int Width { get; set; } public int Width { get; set; }
/// <summary>
/// Gets or sets the Height.
/// </summary>
public int Height { get; set; } public int Height { get; set; }
/// <summary> public string Depth { get; set; }
/// Gets or sets the Depth.
/// </summary>
public string Depth { get; set; } = string.Empty;
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() public override string ToString()
{ {
return string.Format(CultureInfo.InvariantCulture, "{0}x{1}", Height, Width); return string.Format(
CultureInfo.InvariantCulture,
"{0}x{1}",
Height,
Width);
} }
} }
} }
+9 -24
View File
@@ -1,36 +1,21 @@
#pragma warning disable CS1591
namespace Emby.Dlna.Common namespace Emby.Dlna.Common
{ {
/// <summary>
/// Defines the <see cref="DeviceService" />.
/// </summary>
public class DeviceService public class DeviceService
{ {
/// <summary> public string ServiceType { get; set; }
/// Gets or sets the Service Type.
/// </summary>
public string ServiceType { get; set; } = string.Empty;
/// <summary> public string ServiceId { get; set; }
/// Gets or sets the Service Id.
/// </summary>
public string ServiceId { get; set; } = string.Empty;
/// <summary> public string ScpdUrl { get; set; }
/// Gets or sets the Scpd Url.
/// </summary>
public string ScpdUrl { get; set; } = string.Empty;
/// <summary> public string ControlUrl { get; set; }
/// Gets or sets the Control Url.
/// </summary>
public string ControlUrl { get; set; } = string.Empty;
/// <summary> public string EventSubUrl { get; set; }
/// Gets or sets the EventSubUrl.
/// </summary>
public string EventSubUrl { get; set; } = string.Empty;
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() => ServiceId; public override string ToString()
=> ServiceId;
} }
} }
+8 -15
View File
@@ -1,31 +1,24 @@
#pragma warning disable CS1591
using System.Collections.Generic; using System.Collections.Generic;
namespace Emby.Dlna.Common namespace Emby.Dlna.Common
{ {
/// <summary>
/// Defines the <see cref="ServiceAction" />.
/// </summary>
public class ServiceAction public class ServiceAction
{ {
/// <summary>
/// Initializes a new instance of the <see cref="ServiceAction"/> class.
/// </summary>
public ServiceAction() public ServiceAction()
{ {
ArgumentList = new List<Argument>(); ArgumentList = new List<Argument>();
} }
/// <summary> public string Name { get; set; }
/// Gets or sets the name of the action.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary> public List<Argument> ArgumentList { get; set; }
/// Gets the ArgumentList.
/// </summary>
public List<Argument> ArgumentList { get; }
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() => Name; public override string ToString()
{
return Name;
}
} }
} }
+12 -20
View File
@@ -1,34 +1,26 @@
#pragma warning disable CS1591
using System; using System;
using System.Collections.Generic;
namespace Emby.Dlna.Common namespace Emby.Dlna.Common
{ {
/// <summary>
/// Defines the <see cref="StateVariable" />.
/// </summary>
public class StateVariable public class StateVariable
{ {
/// <summary> public StateVariable()
/// Gets or sets the name of the state variable. {
/// </summary> AllowedValues = Array.Empty<string>();
public string Name { get; set; } = string.Empty; }
/// <summary> public string Name { get; set; }
/// Gets or sets the data type of the state variable.
/// </summary> public string DataType { get; set; }
public string DataType { get; set; } = string.Empty;
/// <summary>
/// Gets or sets a value indicating whether it sends events.
/// </summary>
public bool SendsEvents { get; set; } public bool SendsEvents { get; set; }
/// <summary> public string[] AllowedValues { get; set; }
/// Gets or sets the allowed values range.
/// </summary>
public IReadOnlyList<string> AllowedValues { get; set; } = Array.Empty<string>();
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() => Name; public override string ToString()
=> Name;
} }
} }
+5 -64
View File
@@ -2,14 +2,8 @@
namespace Emby.Dlna.Configuration namespace Emby.Dlna.Configuration
{ {
/// <summary>
/// The DlnaOptions class contains the user definable parameters for the dlna subsystems.
/// </summary>
public class DlnaOptions public class DlnaOptions
{ {
/// <summary>
/// Initializes a new instance of the <see cref="DlnaOptions"/> class.
/// </summary>
public DlnaOptions() public DlnaOptions()
{ {
EnablePlayTo = true; EnablePlayTo = true;
@@ -17,76 +11,23 @@ namespace Emby.Dlna.Configuration
BlastAliveMessages = true; BlastAliveMessages = true;
SendOnlyMatchedHost = true; SendOnlyMatchedHost = true;
ClientDiscoveryIntervalSeconds = 60; ClientDiscoveryIntervalSeconds = 60;
AliveMessageIntervalSeconds = 1800; BlastAliveMessageIntervalSeconds = 1800;
} }
/// <summary>
/// Gets or sets a value indicating whether gets or sets a value to indicate the status of the dlna playTo subsystem.
/// </summary>
public bool EnablePlayTo { get; set; } public bool EnablePlayTo { get; set; }
/// <summary>
/// Gets or sets a value indicating whether gets or sets a value to indicate the status of the dlna server subsystem.
/// </summary>
public bool EnableServer { get; set; } public bool EnableServer { get; set; }
/// <summary>
/// Gets or sets a value indicating whether detailed dlna server logs are sent to the console/log.
/// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
/// </summary>
public bool EnableDebugLog { get; set; } public bool EnableDebugLog { get; set; }
/// <summary> public bool BlastAliveMessages { get; set; }
/// Gets or sets a value indicating whether whether detailed playTo debug logs are sent to the console/log.
/// If the setting "Emby.Dlna.PlayTo": "Debug" msut be set in logging.default.json for this property to work. public bool SendOnlyMatchedHost { get; set; }
/// </summary>
public bool EnablePlayToTracing { get; set; }
/// <summary>
/// Gets or sets the ssdp client discovery interval time (in seconds).
/// This is the time after which the server will send a ssdp search request.
/// </summary>
public int ClientDiscoveryIntervalSeconds { get; set; } public int ClientDiscoveryIntervalSeconds { get; set; }
/// <summary> public int BlastAliveMessageIntervalSeconds { get; set; }
/// Gets or sets the frequency at which ssdp alive notifications are transmitted.
/// </summary>
public int AliveMessageIntervalSeconds { get; set; }
/// <summary>
/// Gets or sets the frequency at which ssdp alive notifications are transmitted. MIGRATING - TO BE REMOVED ONCE WEB HAS BEEN ALTERED.
/// </summary>
public int BlastAliveMessageIntervalSeconds
{
get
{
return AliveMessageIntervalSeconds;
}
set
{
AliveMessageIntervalSeconds = value;
}
}
/// <summary>
/// Gets or sets the default user account that the dlna server uses.
/// </summary>
public string DefaultUserId { get; set; } public string DefaultUserId { get; set; }
/// <summary>
/// Gets or sets a value indicating whether playTo device profiles should be created.
/// </summary>
public bool AutoCreatePlayToProfiles { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to blast alive messages.
/// </summary>
public bool BlastAliveMessages { get; set; } = true;
/// <summary>
/// gets or sets a value indicating whether to send only matched host.
/// </summary>
public bool SendOnlyMatchedHost { get; set; } = true;
} }
} }
+16
View File
@@ -1,6 +1,7 @@
#nullable enable #nullable enable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System.Collections.Generic;
using Emby.Dlna.Configuration; using Emby.Dlna.Configuration;
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
@@ -13,4 +14,19 @@ namespace Emby.Dlna
return manager.GetConfiguration<DlnaOptions>("dlna"); return manager.GetConfiguration<DlnaOptions>("dlna");
} }
} }
public class DlnaConfigurationFactory : IConfigurationFactory
{
public IEnumerable<ConfigurationStore> GetConfigurations()
{
return new ConfigurationStore[]
{
new ConfigurationStore
{
Key = "dlna",
ConfigurationType = typeof (DlnaOptions)
}
};
}
}
} }
@@ -0,0 +1,45 @@
#pragma warning disable CS1591
using System.Threading.Tasks;
using Emby.Dlna.Service;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna;
using Microsoft.Extensions.Logging;
namespace Emby.Dlna.ConnectionManager
{
public class ConnectionManager : BaseService, IConnectionManager
{
private readonly IDlnaManager _dlna;
private readonly ILogger _logger;
private readonly IServerConfigurationManager _config;
public ConnectionManager(
IDlnaManager dlna,
IServerConfigurationManager config,
ILogger<ConnectionManager> logger,
IHttpClient httpClient)
: base(logger, httpClient)
{
_dlna = dlna;
_config = config;
_logger = logger;
}
/// <inheritdoc />
public string GetServiceXml()
{
return new ConnectionManagerXmlBuilder().GetXml();
}
/// <inheritdoc />
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
{
var profile = _dlna.GetProfile(request.Headers) ??
_dlna.GetDefaultProfile();
return new ControlHandler(_config, _logger, profile).ProcessControlRequestAsync(request);
}
}
}
@@ -1,53 +0,0 @@
#pragma warning disable CS1591
using System.Net.Http;
using System.Threading.Tasks;
using Emby.Dlna.Service;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna;
using Microsoft.Extensions.Logging;
namespace Emby.Dlna.ConnectionManager
{
/// <summary>
/// Defines the <see cref="ConnectionManagerService" />.
/// </summary>
public class ConnectionManagerService : BaseService, IConnectionManager
{
private readonly IDlnaManager _dlna;
private readonly IServerConfigurationManager _config;
/// <summary>
/// Initializes a new instance of the <see cref="ConnectionManagerService"/> class.
/// </summary>
/// <param name="dlna">The <see cref="IDlnaManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
/// <param name="logger">The <see cref="ILogger{ConnectionManagerService}"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
public ConnectionManagerService(
IDlnaManager dlna,
IServerConfigurationManager config,
ILogger<ConnectionManagerService> logger,
IHttpClientFactory httpClientFactory)
: base(logger, httpClientFactory)
{
_dlna = dlna;
_config = config;
}
/// <inheritdoc />
public string GetServiceXml()
{
return ConnectionManagerXmlBuilder.GetXml();
}
/// <inheritdoc />
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
{
var profile = _dlna.GetProfile(request.Headers) ??
_dlna.GetDefaultProfile();
return new ControlHandler(_config, Logger, profile).ProcessControlRequestAsync(request);
}
}
}
@@ -6,57 +6,45 @@ using Emby.Dlna.Service;
namespace Emby.Dlna.ConnectionManager namespace Emby.Dlna.ConnectionManager
{ {
/// <summary> public class ConnectionManagerXmlBuilder
/// Defines the <see cref="ConnectionManagerXmlBuilder" />.
/// </summary>
public static class ConnectionManagerXmlBuilder
{ {
/// <summary> public string GetXml()
/// Gets the ConnectionManager:1 service template.
/// See http://upnp.org/specs/av/UPnP-av-ConnectionManager-v1-Service.pdf.
/// </summary>
/// <returns>An XML description of this service.</returns>
public static string GetXml()
{ {
return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables()); return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), GetStateVariables());
} }
/// <summary>
/// Get the list of state variables for this invocation.
/// </summary>
/// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
private static IEnumerable<StateVariable> GetStateVariables() private static IEnumerable<StateVariable> GetStateVariables()
{ {
var list = new List<StateVariable> var list = new List<StateVariable>();
list.Add(new StateVariable
{ {
new StateVariable Name = "SourceProtocolInfo",
{ DataType = "string",
Name = "SourceProtocolInfo", SendsEvents = true
DataType = "string", });
SendsEvents = true
},
new StateVariable list.Add(new StateVariable
{ {
Name = "SinkProtocolInfo", Name = "SinkProtocolInfo",
DataType = "string", DataType = "string",
SendsEvents = true SendsEvents = true
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "CurrentConnectionIDs", Name = "CurrentConnectionIDs",
DataType = "string", DataType = "string",
SendsEvents = true SendsEvents = true
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_ConnectionStatus", Name = "A_ARG_TYPE_ConnectionStatus",
DataType = "string", DataType = "string",
SendsEvents = false, SendsEvents = false,
AllowedValues = new[] AllowedValues = new string[]
{ {
"OK", "OK",
"ContentFormatMismatch", "ContentFormatMismatch",
@@ -64,56 +52,55 @@ namespace Emby.Dlna.ConnectionManager
"UnreliableChannel", "UnreliableChannel",
"Unknown" "Unknown"
} }
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_ConnectionManager", Name = "A_ARG_TYPE_ConnectionManager",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_Direction", Name = "A_ARG_TYPE_Direction",
DataType = "string", DataType = "string",
SendsEvents = false, SendsEvents = false,
AllowedValues = new[] AllowedValues = new string[]
{ {
"Output", "Output",
"Input" "Input"
} }
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_ProtocolInfo", Name = "A_ARG_TYPE_ProtocolInfo",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_ConnectionID", Name = "A_ARG_TYPE_ConnectionID",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_AVTransportID", Name = "A_ARG_TYPE_AVTransportID",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_RcsID", Name = "A_ARG_TYPE_RcsID",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
} });
};
return list; return list;
} }
@@ -11,19 +11,10 @@ using Microsoft.Extensions.Logging;
namespace Emby.Dlna.ConnectionManager namespace Emby.Dlna.ConnectionManager
{ {
/// <summary>
/// Defines the <see cref="ControlHandler" />.
/// </summary>
public class ControlHandler : BaseControlHandler public class ControlHandler : BaseControlHandler
{ {
private readonly DeviceProfile _profile; private readonly DeviceProfile _profile;
/// <summary>
/// Initializes a new instance of the <see cref="ControlHandler"/> class.
/// </summary>
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
/// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
/// <param name="profile">The <see cref="DeviceProfile"/> for use with the <see cref="ControlHandler"/> instance.</param>
public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile) public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
: base(config, logger) : base(config, logger)
{ {
@@ -42,10 +33,6 @@ namespace Emby.Dlna.ConnectionManager
throw new ResourceNotFoundException("Unexpected control request name: " + methodName); throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
} }
/// <summary>
/// Builds the response to the GetProtocolInfo request.
/// </summary>
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
private void HandleGetProtocolInfo(XmlWriter xmlWriter) private void HandleGetProtocolInfo(XmlWriter xmlWriter)
{ {
xmlWriter.WriteElementString("Source", _profile.ProtocolInfo); xmlWriter.WriteElementString("Source", _profile.ProtocolInfo);
@@ -5,16 +5,9 @@ using Emby.Dlna.Common;
namespace Emby.Dlna.ConnectionManager namespace Emby.Dlna.ConnectionManager
{ {
/// <summary> public class ServiceActionListBuilder
/// Defines the <see cref="ServiceActionListBuilder" />.
/// </summary>
public static class ServiceActionListBuilder
{ {
/// <summary> public IEnumerable<ServiceAction> GetActions()
/// Returns an enumerable of the ConnectionManagar:1 DLNA actions.
/// </summary>
/// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
public static IEnumerable<ServiceAction> GetActions()
{ {
var list = new List<ServiceAction> var list = new List<ServiceAction>
{ {
@@ -28,10 +21,6 @@ namespace Emby.Dlna.ConnectionManager
return list; return list;
} }
/// <summary>
/// Returns the action details for "PrepareForConnection".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction PrepareForConnection() private static ServiceAction PrepareForConnection()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -91,10 +80,6 @@ namespace Emby.Dlna.ConnectionManager
return action; return action;
} }
/// <summary>
/// Returns the action details for "GetCurrentConnectionInfo".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetCurrentConnectionInfo() private static ServiceAction GetCurrentConnectionInfo()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -161,11 +146,7 @@ namespace Emby.Dlna.ConnectionManager
return action; return action;
} }
/// <summary> private ServiceAction GetProtocolInfo()
/// Returns the action details for "GetProtocolInfo".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetProtocolInfo()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -189,11 +170,7 @@ namespace Emby.Dlna.ConnectionManager
return action; return action;
} }
/// <summary> private ServiceAction GetCurrentConnectionIDs()
/// Returns the action details for "GetCurrentConnectionIDs".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetCurrentConnectionIDs()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -210,11 +187,7 @@ namespace Emby.Dlna.ConnectionManager
return action; return action;
} }
/// <summary> private ServiceAction ConnectionComplete()
/// Returns the action details for "ConnectionComplete".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction ConnectionComplete()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -2,11 +2,11 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.Dlna.Service; using Emby.Dlna.Service;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
@@ -19,10 +19,7 @@ using Microsoft.Extensions.Logging;
namespace Emby.Dlna.ContentDirectory namespace Emby.Dlna.ContentDirectory
{ {
/// <summary> public class ContentDirectory : BaseService, IContentDirectory
/// Defines the <see cref="ContentDirectoryService" />.
/// </summary>
public class ContentDirectoryService : BaseService, IContentDirectory
{ {
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
@@ -36,31 +33,15 @@ namespace Emby.Dlna.ContentDirectory
private readonly IMediaEncoder _mediaEncoder; private readonly IMediaEncoder _mediaEncoder;
private readonly ITVSeriesManager _tvSeriesManager; private readonly ITVSeriesManager _tvSeriesManager;
/// <summary> public ContentDirectory(
/// Initializes a new instance of the <see cref="ContentDirectoryService"/> class.
/// </summary>
/// <param name="dlna">The <see cref="IDlnaManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="userDataManager">The <see cref="IUserDataManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="imageProcessor">The <see cref="IImageProcessor"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="libraryManager">The <see cref="ILibraryManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="config">The <see cref="IServerConfigurationManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="userManager">The <see cref="IUserManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="logger">The <see cref="ILogger{ContentDirectoryService}"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="httpClient">The <see cref="IHttpClientFactory"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="localization">The <see cref="ILocalizationManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="mediaSourceManager">The <see cref="IMediaSourceManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="userViewManager">The <see cref="IUserViewManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="mediaEncoder">The <see cref="IMediaEncoder"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
/// <param name="tvSeriesManager">The <see cref="ITVSeriesManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
public ContentDirectoryService(
IDlnaManager dlna, IDlnaManager dlna,
IUserDataManager userDataManager, IUserDataManager userDataManager,
IImageProcessor imageProcessor, IImageProcessor imageProcessor,
ILibraryManager libraryManager, ILibraryManager libraryManager,
IServerConfigurationManager config, IServerConfigurationManager config,
IUserManager userManager, IUserManager userManager,
ILogger<ContentDirectoryService> logger, ILogger<ContentDirectory> logger,
IHttpClientFactory httpClient, IHttpClient httpClient,
ILocalizationManager localization, ILocalizationManager localization,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IUserViewManager userViewManager, IUserViewManager userViewManager,
@@ -81,10 +62,7 @@ namespace Emby.Dlna.ContentDirectory
_tvSeriesManager = tvSeriesManager; _tvSeriesManager = tvSeriesManager;
} }
/// <summary> private int SystemUpdateId
/// Gets the system id. (A unique id which changes on when our definition changes.)
/// </summary>
private static int SystemUpdateId
{ {
get get
{ {
@@ -97,18 +75,14 @@ namespace Emby.Dlna.ContentDirectory
/// <inheritdoc /> /// <inheritdoc />
public string GetServiceXml() public string GetServiceXml()
{ {
return ContentDirectoryXmlBuilder.GetXml(); return new ContentDirectoryXmlBuilder().GetXml();
} }
/// <inheritdoc /> /// <inheritdoc />
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request) public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
{ {
if (request == null) var profile = _dlna.GetProfile(request.Headers) ??
{ _dlna.GetDefaultProfile();
throw new ArgumentNullException(nameof(request));
}
var profile = _dlna.GetProfile(request.Headers) ?? _dlna.GetDefaultProfile();
var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase)); var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase));
@@ -133,11 +107,6 @@ namespace Emby.Dlna.ContentDirectory
.ProcessControlRequestAsync(request); .ProcessControlRequestAsync(request);
} }
/// <summary>
/// Get the user stored in the device profile.
/// </summary>
/// <param name="profile">The <see cref="DeviceProfile"/>.</param>
/// <returns>The <see cref="User"/>.</returns>
private User GetUser(DeviceProfile profile) private User GetUser(DeviceProfile profile)
{ {
if (!string.IsNullOrEmpty(profile.UserId)) if (!string.IsNullOrEmpty(profile.UserId))
@@ -6,154 +6,142 @@ using Emby.Dlna.Service;
namespace Emby.Dlna.ContentDirectory namespace Emby.Dlna.ContentDirectory
{ {
/// <summary> public class ContentDirectoryXmlBuilder
/// Defines the <see cref="ContentDirectoryXmlBuilder" />.
/// </summary>
public static class ContentDirectoryXmlBuilder
{ {
/// <summary> public string GetXml()
/// Gets the ContentDirectory:1 service template.
/// See http://upnp.org/specs/av/UPnP-av-ContentDirectory-v1-Service.pdf.
/// </summary>
/// <returns>An XML description of this service.</returns>
public static string GetXml()
{ {
return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables()); return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(),
GetStateVariables());
} }
/// <summary>
/// Get the list of state variables for this invocation.
/// </summary>
/// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
private static IEnumerable<StateVariable> GetStateVariables() private static IEnumerable<StateVariable> GetStateVariables()
{ {
var list = new List<StateVariable> var list = new List<StateVariable>();
list.Add(new StateVariable
{ {
new StateVariable Name = "A_ARG_TYPE_Filter",
{ DataType = "string",
Name = "A_ARG_TYPE_Filter", SendsEvents = false
DataType = "string", });
SendsEvents = false
},
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_SortCriteria", Name = "A_ARG_TYPE_SortCriteria",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_Index", Name = "A_ARG_TYPE_Index",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_Count", Name = "A_ARG_TYPE_Count",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_UpdateID", Name = "A_ARG_TYPE_UpdateID",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "SearchCapabilities", Name = "SearchCapabilities",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "SortCapabilities", Name = "SortCapabilities",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "SystemUpdateID", Name = "SystemUpdateID",
DataType = "ui4", DataType = "ui4",
SendsEvents = true SendsEvents = true
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_SearchCriteria", Name = "A_ARG_TYPE_SearchCriteria",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_Result", Name = "A_ARG_TYPE_Result",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_ObjectID", Name = "A_ARG_TYPE_ObjectID",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_BrowseFlag", Name = "A_ARG_TYPE_BrowseFlag",
DataType = "string", DataType = "string",
SendsEvents = false, SendsEvents = false,
AllowedValues = new[] AllowedValues = new string[]
{ {
"BrowseMetadata", "BrowseMetadata",
"BrowseDirectChildren" "BrowseDirectChildren"
} }
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_BrowseLetter", Name = "A_ARG_TYPE_BrowseLetter",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_CategoryType", Name = "A_ARG_TYPE_CategoryType",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_RID", Name = "A_ARG_TYPE_RID",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_PosSec", Name = "A_ARG_TYPE_PosSec",
DataType = "ui4", DataType = "ui4",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_Featurelist", Name = "A_ARG_TYPE_Featurelist",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
} });
};
return list; return list;
} }
File diff suppressed because it is too large Load Diff
-36
View File
@@ -1,36 +0,0 @@
#pragma warning disable CS1591
using MediaBrowser.Controller.Entities;
namespace Emby.Dlna.ContentDirectory
{
/// <summary>
/// Defines the <see cref="ServerItem" />.
/// </summary>
internal class ServerItem
{
/// <summary>
/// Initializes a new instance of the <see cref="ServerItem"/> class.
/// </summary>
/// <param name="item">The <see cref="BaseItem"/>.</param>
public ServerItem(BaseItem item)
{
Item = item;
if (item is IItemByName && !(item is Folder))
{
StubType = Dlna.ContentDirectory.StubType.Folder;
}
}
/// <summary>
/// Gets or sets the underlying base item.
/// </summary>
public BaseItem Item { get; set; }
/// <summary>
/// Gets or sets the DLNA item type.
/// </summary>
public StubType? StubType { get; set; }
}
}
@@ -1,18 +1,13 @@
#pragma warning disable CS1591
using System.Collections.Generic; using System.Collections.Generic;
using Emby.Dlna.Common; using Emby.Dlna.Common;
namespace Emby.Dlna.ContentDirectory namespace Emby.Dlna.ContentDirectory
{ {
/// <summary> public class ServiceActionListBuilder
/// Defines the <see cref="ServiceActionListBuilder" />.
/// </summary>
public static class ServiceActionListBuilder
{ {
/// <summary> public IEnumerable<ServiceAction> GetActions()
/// Returns a list of services that this instance provides.
/// </summary>
/// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
public static IEnumerable<ServiceAction> GetActions()
{ {
return new[] return new[]
{ {
@@ -27,10 +22,6 @@ namespace Emby.Dlna.ContentDirectory
}; };
} }
/// <summary>
/// Returns the action details for "GetSystemUpdateID".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetGetSystemUpdateIDAction() private static ServiceAction GetGetSystemUpdateIDAction()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -48,10 +39,6 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary>
/// Returns the action details for "GetSearchCapabilities".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetSearchCapabilitiesAction() private static ServiceAction GetSearchCapabilitiesAction()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -69,10 +56,6 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary>
/// Returns the action details for "GetSortCapabilities".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetSortCapabilitiesAction() private static ServiceAction GetSortCapabilitiesAction()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -90,10 +73,6 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary>
/// Returns the action details for "X_GetFeatureList".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetX_GetFeatureListAction() private static ServiceAction GetX_GetFeatureListAction()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -111,10 +90,6 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary>
/// Returns the action details for "Search".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetSearchAction() private static ServiceAction GetSearchAction()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -195,11 +170,7 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary> private ServiceAction GetBrowseAction()
/// Returns the action details for "Browse".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetBrowseAction()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -279,11 +250,7 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary> private ServiceAction GetBrowseByLetterAction()
/// Returns the action details for "X_BrowseByLetter".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetBrowseByLetterAction()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -370,11 +337,7 @@ namespace Emby.Dlna.ContentDirectory
return action; return action;
} }
/// <summary> private ServiceAction GetXSetBookmarkAction()
/// Returns the action details for "X_SetBookmark".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetXSetBookmarkAction()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
-31
View File
@@ -1,31 +0,0 @@
#pragma warning disable CS1591
#pragma warning disable SA1602
namespace Emby.Dlna.ContentDirectory
{
/// <summary>
/// Defines the DLNA item types.
/// </summary>
public enum StubType
{
Folder = 0,
Latest = 2,
Playlists = 3,
Albums = 4,
AlbumArtists = 5,
Artists = 6,
Songs = 7,
Genres = 8,
FavoriteSongs = 9,
FavoriteArtists = 10,
FavoriteAlbums = 11,
ContinueWatching = 12,
Movies = 13,
Collections = 14,
Favorites = 15,
NextUp = 16,
Series = 17,
FavoriteSeries = 18,
FavoriteEpisodes = 19
}
}
+6 -6
View File
@@ -7,17 +7,17 @@ namespace Emby.Dlna
{ {
public class ControlRequest public class ControlRequest
{ {
public ControlRequest(IHeaderDictionary headers) public IHeaderDictionary Headers { get; set; }
{
Headers = headers;
}
public IHeaderDictionary Headers { get; }
public Stream InputXml { get; set; } public Stream InputXml { get; set; }
public string TargetServerUuId { get; set; } public string TargetServerUuId { get; set; }
public string RequestedUrl { get; set; } public string RequestedUrl { get; set; }
public ControlRequest()
{
Headers = new HeaderDictionary();
}
} }
} }
+1 -7
View File
@@ -11,16 +11,10 @@ namespace Emby.Dlna
Headers = new Dictionary<string, string>(); Headers = new Dictionary<string, string>();
} }
public IDictionary<string, string> Headers { get; } public IDictionary<string, string> Headers { get; set; }
public string Xml { get; set; } public string Xml { get; set; }
public bool IsSuccessful { get; set; } public bool IsSuccessful { get; set; }
/// <inheritdoc />
public override string ToString()
{
return Xml;
}
} }
} }
+92 -75
View File
@@ -34,13 +34,13 @@ namespace Emby.Dlna.Didl
{ {
public class DidlBuilder public class DidlBuilder
{ {
private const string NsDidl = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
private const string NsDc = "http://purl.org/dc/elements/1.1/";
private const string NsUpnp = "urn:schemas-upnp-org:metadata-1-0/upnp/";
private const string NsDlna = "urn:schemas-dlna-org:metadata-1-0/";
private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly CultureInfo _usCulture = new CultureInfo("en-US");
private const string NS_DIDL = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
private const string NS_DC = "http://purl.org/dc/elements/1.1/";
private const string NS_UPNP = "urn:schemas-upnp-org:metadata-1-0/upnp/";
private const string NS_DLNA = "urn:schemas-dlna-org:metadata-1-0/";
private readonly DeviceProfile _profile; private readonly DeviceProfile _profile;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly string _serverAddress; private readonly string _serverAddress;
@@ -96,16 +96,15 @@ namespace Emby.Dlna.Didl
using (StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8)) using (StringWriter builder = new StringWriterWithEncoding(Encoding.UTF8))
{ {
// If this using are changed to single lines, then write.Flush needs to be appended before the return.
using (var writer = XmlWriter.Create(builder, settings)) using (var writer = XmlWriter.Create(builder, settings))
{ {
// writer.WriteStartDocument(); // writer.WriteStartDocument();
writer.WriteStartElement(string.Empty, "DIDL-Lite", NsDidl); writer.WriteStartElement(string.Empty, "DIDL-Lite", NS_DIDL);
writer.WriteAttributeString("xmlns", "dc", null, NsDc); writer.WriteAttributeString("xmlns", "dc", null, NS_DC);
writer.WriteAttributeString("xmlns", "dlna", null, NsDlna); writer.WriteAttributeString("xmlns", "dlna", null, NS_DLNA);
writer.WriteAttributeString("xmlns", "upnp", null, NsUpnp); writer.WriteAttributeString("xmlns", "upnp", null, NS_UPNP);
// didl.SetAttribute("xmlns:sec", NS_SEC); // didl.SetAttribute("xmlns:sec", NS_SEC);
WriteXmlRootAttributes(_profile, writer); WriteXmlRootAttributes(_profile, writer);
@@ -124,7 +123,7 @@ namespace Emby.Dlna.Didl
{ {
foreach (var att in profile.XmlRootAttributes) foreach (var att in profile.XmlRootAttributes)
{ {
var parts = att.Name.Split(':', StringSplitOptions.RemoveEmptyEntries); var parts = att.Name.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 2) if (parts.Length == 2)
{ {
writer.WriteAttributeString(parts[0], parts[1], null, att.Value); writer.WriteAttributeString(parts[0], parts[1], null, att.Value);
@@ -148,7 +147,7 @@ namespace Emby.Dlna.Didl
{ {
var clientId = GetClientId(item, null); var clientId = GetClientId(item, null);
writer.WriteStartElement(string.Empty, "item", NsDidl); writer.WriteStartElement(string.Empty, "item", NS_DIDL);
writer.WriteAttributeString("restricted", "1"); writer.WriteAttributeString("restricted", "1");
writer.WriteAttributeString("id", clientId); writer.WriteAttributeString("id", clientId);
@@ -208,8 +207,7 @@ namespace Emby.Dlna.Didl
var targetWidth = streamInfo.TargetWidth; var targetWidth = streamInfo.TargetWidth;
var targetHeight = streamInfo.TargetHeight; var targetHeight = streamInfo.TargetHeight;
var contentFeatureList = new ContentFeatureBuilder(_profile).BuildVideoHeader( var contentFeatureList = new ContentFeatureBuilder(_profile).BuildVideoHeader(streamInfo.Container,
streamInfo.Container,
streamInfo.TargetVideoCodec.FirstOrDefault(), streamInfo.TargetVideoCodec.FirstOrDefault(),
streamInfo.TargetAudioCodec.FirstOrDefault(), streamInfo.TargetAudioCodec.FirstOrDefault(),
targetWidth, targetWidth,
@@ -281,7 +279,7 @@ namespace Emby.Dlna.Didl
} }
else if (string.Equals(subtitleMode, "smi", StringComparison.OrdinalIgnoreCase)) else if (string.Equals(subtitleMode, "smi", StringComparison.OrdinalIgnoreCase))
{ {
writer.WriteStartElement(string.Empty, "res", NsDidl); writer.WriteStartElement(string.Empty, "res", NS_DIDL);
writer.WriteAttributeString("protocolInfo", "http-get:*:smi/caption:*"); writer.WriteAttributeString("protocolInfo", "http-get:*:smi/caption:*");
@@ -290,7 +288,7 @@ namespace Emby.Dlna.Didl
} }
else else
{ {
writer.WriteStartElement(string.Empty, "res", NsDidl); writer.WriteStartElement(string.Empty, "res", NS_DIDL);
var protocolInfo = string.Format( var protocolInfo = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"http-get:*:text/{0}:*", "http-get:*:text/{0}:*",
@@ -306,7 +304,7 @@ namespace Emby.Dlna.Didl
private void AddVideoResource(XmlWriter writer, Filter filter, string contentFeatures, StreamInfo streamInfo) private void AddVideoResource(XmlWriter writer, Filter filter, string contentFeatures, StreamInfo streamInfo)
{ {
writer.WriteStartElement(string.Empty, "res", NsDidl); writer.WriteStartElement(string.Empty, "res", NS_DIDL);
var url = NormalizeDlnaMediaUrl(streamInfo.ToUrl(_serverAddress, _accessToken)); var url = NormalizeDlnaMediaUrl(streamInfo.ToUrl(_serverAddress, _accessToken));
@@ -366,8 +364,7 @@ namespace Emby.Dlna.Didl
writer.WriteAttributeString("bitrate", totalBitrate.Value.ToString(_usCulture)); writer.WriteAttributeString("bitrate", totalBitrate.Value.ToString(_usCulture));
} }
var mediaProfile = _profile.GetVideoMediaProfile( var mediaProfile = _profile.GetVideoMediaProfile(streamInfo.Container,
streamInfo.Container,
streamInfo.TargetAudioCodec.FirstOrDefault(), streamInfo.TargetAudioCodec.FirstOrDefault(),
streamInfo.TargetVideoCodec.FirstOrDefault(), streamInfo.TargetVideoCodec.FirstOrDefault(),
streamInfo.TargetAudioBitrate, streamInfo.TargetAudioBitrate,
@@ -528,7 +525,7 @@ namespace Emby.Dlna.Didl
private void AddAudioResource(XmlWriter writer, BaseItem audio, string deviceId, Filter filter, StreamInfo streamInfo = null) private void AddAudioResource(XmlWriter writer, BaseItem audio, string deviceId, Filter filter, StreamInfo streamInfo = null)
{ {
writer.WriteStartElement(string.Empty, "res", NsDidl); writer.WriteStartElement(string.Empty, "res", NS_DIDL);
if (streamInfo == null) if (streamInfo == null)
{ {
@@ -585,8 +582,7 @@ namespace Emby.Dlna.Didl
writer.WriteAttributeString("bitrate", targetAudioBitrate.Value.ToString(_usCulture)); writer.WriteAttributeString("bitrate", targetAudioBitrate.Value.ToString(_usCulture));
} }
var mediaProfile = _profile.GetAudioMediaProfile( var mediaProfile = _profile.GetAudioMediaProfile(streamInfo.Container,
streamInfo.Container,
streamInfo.TargetAudioCodec.FirstOrDefault(), streamInfo.TargetAudioCodec.FirstOrDefault(),
targetChannels, targetChannels,
targetAudioBitrate, targetAudioBitrate,
@@ -599,8 +595,7 @@ namespace Emby.Dlna.Didl
? MimeTypes.GetMimeType(filename) ? MimeTypes.GetMimeType(filename)
: mediaProfile.MimeType; : mediaProfile.MimeType;
var contentFeatures = new ContentFeatureBuilder(_profile).BuildAudioHeader( var contentFeatures = new ContentFeatureBuilder(_profile).BuildAudioHeader(streamInfo.Container,
streamInfo.Container,
streamInfo.TargetAudioCodec.FirstOrDefault(), streamInfo.TargetAudioCodec.FirstOrDefault(),
targetAudioBitrate, targetAudioBitrate,
targetSampleRate, targetSampleRate,
@@ -631,7 +626,7 @@ namespace Emby.Dlna.Didl
public void WriteFolderElement(XmlWriter writer, BaseItem folder, StubType? stubType, BaseItem context, int childCount, Filter filter, string requestedId = null) public void WriteFolderElement(XmlWriter writer, BaseItem folder, StubType? stubType, BaseItem context, int childCount, Filter filter, string requestedId = null)
{ {
writer.WriteStartElement(string.Empty, "container", NsDidl); writer.WriteStartElement(string.Empty, "container", NS_DIDL);
writer.WriteAttributeString("restricted", "1"); writer.WriteAttributeString("restricted", "1");
writer.WriteAttributeString("searchable", "1"); writer.WriteAttributeString("searchable", "1");
@@ -718,7 +713,7 @@ namespace Emby.Dlna.Didl
// MediaMonkey for example won't display content without a title // MediaMonkey for example won't display content without a title
// if (filter.Contains("dc:title")) // if (filter.Contains("dc:title"))
{ {
AddValue(writer, "dc", "title", GetDisplayName(item, itemStubType, context), NsDc); AddValue(writer, "dc", "title", GetDisplayName(item, itemStubType, context), NS_DC);
} }
WriteObjectClass(writer, item, itemStubType); WriteObjectClass(writer, item, itemStubType);
@@ -727,7 +722,7 @@ namespace Emby.Dlna.Didl
{ {
if (item.PremiereDate.HasValue) if (item.PremiereDate.HasValue)
{ {
AddValue(writer, "dc", "date", item.PremiereDate.Value.ToString("o", CultureInfo.InvariantCulture), NsDc); AddValue(writer, "dc", "date", item.PremiereDate.Value.ToString("o", CultureInfo.InvariantCulture), NS_DC);
} }
} }
@@ -735,13 +730,13 @@ namespace Emby.Dlna.Didl
{ {
foreach (var genre in item.Genres) foreach (var genre in item.Genres)
{ {
AddValue(writer, "upnp", "genre", genre, NsUpnp); AddValue(writer, "upnp", "genre", genre, NS_UPNP);
} }
} }
foreach (var studio in item.Studios) foreach (var studio in item.Studios)
{ {
AddValue(writer, "upnp", "publisher", studio, NsUpnp); AddValue(writer, "upnp", "publisher", studio, NS_UPNP);
} }
if (!(item is Folder)) if (!(item is Folder))
@@ -752,29 +747,28 @@ namespace Emby.Dlna.Didl
if (!string.IsNullOrWhiteSpace(desc)) if (!string.IsNullOrWhiteSpace(desc))
{ {
AddValue(writer, "dc", "description", desc, NsDc); AddValue(writer, "dc", "description", desc, NS_DC);
} }
} }
// if (filter.Contains("upnp:longDescription")) // if (filter.Contains("upnp:longDescription"))
// { //{
// if (!string.IsNullOrWhiteSpace(item.Overview)) // if (!string.IsNullOrWhiteSpace(item.Overview))
// { // {
// AddValue(writer, "upnp", "longDescription", item.Overview, NsUpnp); // AddValue(writer, "upnp", "longDescription", item.Overview, NS_UPNP);
// } // }
// } //}
} }
if (!string.IsNullOrEmpty(item.OfficialRating)) if (!string.IsNullOrEmpty(item.OfficialRating))
{ {
if (filter.Contains("dc:rating")) if (filter.Contains("dc:rating"))
{ {
AddValue(writer, "dc", "rating", item.OfficialRating, NsDc); AddValue(writer, "dc", "rating", item.OfficialRating, NS_DC);
} }
if (filter.Contains("upnp:rating")) if (filter.Contains("upnp:rating"))
{ {
AddValue(writer, "upnp", "rating", item.OfficialRating, NsUpnp); AddValue(writer, "upnp", "rating", item.OfficialRating, NS_UPNP);
} }
} }
@@ -786,7 +780,7 @@ namespace Emby.Dlna.Didl
// More types here // More types here
// http://oss.linn.co.uk/repos/Public/LibUpnpCil/DidlLite/UpnpAv/Test/TestDidlLite.cs // http://oss.linn.co.uk/repos/Public/LibUpnpCil/DidlLite/UpnpAv/Test/TestDidlLite.cs
writer.WriteStartElement("upnp", "class", NsUpnp); writer.WriteStartElement("upnp", "class", NS_UPNP);
if (item.IsDisplayedAsFolder || stubType.HasValue) if (item.IsDisplayedAsFolder || stubType.HasValue)
{ {
@@ -887,7 +881,7 @@ namespace Emby.Dlna.Didl
var type = types.FirstOrDefault(i => string.Equals(i, actor.Type, StringComparison.OrdinalIgnoreCase) || string.Equals(i, actor.Role, StringComparison.OrdinalIgnoreCase)) var type = types.FirstOrDefault(i => string.Equals(i, actor.Type, StringComparison.OrdinalIgnoreCase) || string.Equals(i, actor.Role, StringComparison.OrdinalIgnoreCase))
?? PersonType.Actor; ?? PersonType.Actor;
AddValue(writer, "upnp", type.ToLowerInvariant(), actor.Name, NsUpnp); AddValue(writer, "upnp", type.ToLowerInvariant(), actor.Name, NS_UPNP);
} }
} }
@@ -901,8 +895,8 @@ namespace Emby.Dlna.Didl
{ {
foreach (var artist in hasArtists.Artists) foreach (var artist in hasArtists.Artists)
{ {
AddValue(writer, "upnp", "artist", artist, NsUpnp); AddValue(writer, "upnp", "artist", artist, NS_UPNP);
AddValue(writer, "dc", "creator", artist, NsDc); AddValue(writer, "dc", "creator", artist, NS_DC);
// If it doesn't support album artists (musicvideo), then tag as both // If it doesn't support album artists (musicvideo), then tag as both
if (hasAlbumArtists == null) if (hasAlbumArtists == null)
@@ -922,16 +916,16 @@ namespace Emby.Dlna.Didl
if (!string.IsNullOrWhiteSpace(item.Album)) if (!string.IsNullOrWhiteSpace(item.Album))
{ {
AddValue(writer, "upnp", "album", item.Album, NsUpnp); AddValue(writer, "upnp", "album", item.Album, NS_UPNP);
} }
if (item.IndexNumber.HasValue) if (item.IndexNumber.HasValue)
{ {
AddValue(writer, "upnp", "originalTrackNumber", item.IndexNumber.Value.ToString(_usCulture), NsUpnp); AddValue(writer, "upnp", "originalTrackNumber", item.IndexNumber.Value.ToString(_usCulture), NS_UPNP);
if (item is Episode) if (item is Episode)
{ {
AddValue(writer, "upnp", "episodeNumber", item.IndexNumber.Value.ToString(_usCulture), NsUpnp); AddValue(writer, "upnp", "episodeNumber", item.IndexNumber.Value.ToString(_usCulture), NS_UPNP);
} }
} }
} }
@@ -940,7 +934,7 @@ namespace Emby.Dlna.Didl
{ {
try try
{ {
writer.WriteStartElement("upnp", "artist", NsUpnp); writer.WriteStartElement("upnp", "artist", NS_UPNP);
writer.WriteAttributeString("role", "AlbumArtist"); writer.WriteAttributeString("role", "AlbumArtist");
writer.WriteString(name); writer.WriteString(name);
@@ -949,7 +943,7 @@ namespace Emby.Dlna.Didl
} }
catch (XmlException ex) catch (XmlException ex)
{ {
_logger.LogError(ex, "Error adding xml value: {Value}", name); _logger.LogError(ex, "Error adding xml value: {value}", name);
} }
} }
@@ -961,7 +955,7 @@ namespace Emby.Dlna.Didl
} }
catch (XmlException ex) catch (XmlException ex)
{ {
_logger.LogError(ex, "Error adding xml value: {Value}", value); _logger.LogError(ex, "Error adding xml value: {value}", value);
} }
} }
@@ -976,14 +970,14 @@ namespace Emby.Dlna.Didl
var albumartUrlInfo = GetImageUrl(imageInfo, _profile.MaxAlbumArtWidth, _profile.MaxAlbumArtHeight, "jpg"); var albumartUrlInfo = GetImageUrl(imageInfo, _profile.MaxAlbumArtWidth, _profile.MaxAlbumArtHeight, "jpg");
writer.WriteStartElement("upnp", "albumArtURI", NsUpnp); writer.WriteStartElement("upnp", "albumArtURI", NS_UPNP);
writer.WriteAttributeString("dlna", "profileID", NsDlna, _profile.AlbumArtPn); writer.WriteAttributeString("dlna", "profileID", NS_DLNA, _profile.AlbumArtPn);
writer.WriteString(albumartUrlInfo.url); writer.WriteString(albumartUrlInfo.Url);
writer.WriteFullEndElement(); writer.WriteFullEndElement();
// TOOD: Remove these default values // TOOD: Remove these default values
var iconUrlInfo = GetImageUrl(imageInfo, _profile.MaxIconWidth ?? 48, _profile.MaxIconHeight ?? 48, "jpg"); var iconUrlInfo = GetImageUrl(imageInfo, _profile.MaxIconWidth ?? 48, _profile.MaxIconHeight ?? 48, "jpg");
writer.WriteElementString("upnp", "icon", NsUpnp, iconUrlInfo.url); writer.WriteElementString("upnp", "icon", NS_UPNP, iconUrlInfo.Url);
if (!_profile.EnableAlbumArtInDidl) if (!_profile.EnableAlbumArtInDidl)
{ {
@@ -1026,12 +1020,12 @@ namespace Emby.Dlna.Didl
var albumartUrlInfo = GetImageUrl(imageInfo, maxWidth, maxHeight, format); var albumartUrlInfo = GetImageUrl(imageInfo, maxWidth, maxHeight, format);
writer.WriteStartElement(string.Empty, "res", NsDidl); writer.WriteStartElement(string.Empty, "res", NS_DIDL);
// Images must have a reported size or many clients (Bubble upnp), will only use the first thumbnail // Images must have a reported size or many clients (Bubble upnp), will only use the first thumbnail
// rather than using a larger one when available // rather than using a larger one when available
var width = albumartUrlInfo.width ?? maxWidth; var width = albumartUrlInfo.Width ?? maxWidth;
var height = albumartUrlInfo.height ?? maxHeight; var height = albumartUrlInfo.Height ?? maxHeight;
var contentFeatures = new ContentFeatureBuilder(_profile) var contentFeatures = new ContentFeatureBuilder(_profile)
.BuildImageHeader(format, width, height, imageInfo.IsDirectStream, org_Pn); .BuildImageHeader(format, width, height, imageInfo.IsDirectStream, org_Pn);
@@ -1048,7 +1042,7 @@ namespace Emby.Dlna.Didl
"resolution", "resolution",
string.Format(CultureInfo.InvariantCulture, "{0}x{1}", width, height)); string.Format(CultureInfo.InvariantCulture, "{0}x{1}", width, height));
writer.WriteString(albumartUrlInfo.url); writer.WriteString(albumartUrlInfo.Url);
writer.WriteFullEndElement(); writer.WriteFullEndElement();
} }
@@ -1144,6 +1138,7 @@ namespace Emby.Dlna.Didl
if (width == 0 || height == 0) if (width == 0 || height == 0)
{ {
// _imageProcessor.GetImageSize(item, imageInfo);
width = null; width = null;
height = null; height = null;
} }
@@ -1153,6 +1148,18 @@ namespace Emby.Dlna.Didl
height = null; height = null;
} }
// try
//{
// var size = _imageProcessor.GetImageSize(imageInfo);
// width = size.Width;
// height = size.Height;
//}
// catch
//{
//}
var inputFormat = (Path.GetExtension(imageInfo.Path) ?? string.Empty) var inputFormat = (Path.GetExtension(imageInfo.Path) ?? string.Empty)
.TrimStart('.') .TrimStart('.')
.Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase); .Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase);
@@ -1169,6 +1176,30 @@ namespace Emby.Dlna.Didl
}; };
} }
private class ImageDownloadInfo
{
internal Guid ItemId;
internal string ImageTag;
internal ImageType Type;
internal int? Width;
internal int? Height;
internal bool IsDirectStream;
internal string Format;
internal ItemImageInfo ItemImageInfo;
}
private class ImageUrlInfo
{
internal string Url;
internal int? Width;
internal int? Height;
}
public static string GetClientId(BaseItem item, StubType? stubType) public static string GetClientId(BaseItem item, StubType? stubType)
{ {
return GetClientId(item.Id, stubType); return GetClientId(item.Id, stubType);
@@ -1186,7 +1217,7 @@ namespace Emby.Dlna.Didl
return id; return id;
} }
private (string url, int? width, int? height) GetImageUrl(ImageDownloadInfo info, int maxWidth, int maxHeight, string format) private ImageUrlInfo GetImageUrl(ImageDownloadInfo info, int maxWidth, int maxHeight, string format)
{ {
var url = string.Format( var url = string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
@@ -1224,26 +1255,12 @@ namespace Emby.Dlna.Didl
// just lie // just lie
info.IsDirectStream = true; info.IsDirectStream = true;
return (url, width, height); return new ImageUrlInfo
} {
Url = url,
private class ImageDownloadInfo Width = width,
{ Height = height
internal Guid ItemId { get; set; } };
internal string ImageTag { get; set; }
internal ImageType Type { get; set; }
internal int? Width { get; set; }
internal int? Height { get; set; }
internal bool IsDirectStream { get; set; }
internal string Format { get; set; }
internal ItemImageInfo ItemImageInfo { get; set; }
} }
} }
} }
+4 -2
View File
@@ -18,12 +18,14 @@ namespace Emby.Dlna.Didl
{ {
_all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase); _all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
_fields = (filter ?? string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries); _fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
} }
public bool Contains(string field) public bool Contains(string field)
{ {
return _all || Array.Exists(_fields, x => x.Equals(field, StringComparison.OrdinalIgnoreCase)); // Don't bother with this. Some clients (media monkey) use the filter and then don't display very well when very little data comes back.
return true;
// return _all || ListHelper.ContainsIgnoreCase(_fields, field);
} }
} }
} }
+1 -1
View File
@@ -1,5 +1,4 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
#pragma warning disable CA1305
using System; using System;
using System.IO; using System.IO;
@@ -30,6 +29,7 @@ namespace Emby.Dlna.Didl
{ {
} }
public StringWriterWithEncoding(Encoding encoding) public StringWriterWithEncoding(Encoding encoding)
{ {
_encoding = encoding; _encoding = encoding;
-24
View File
@@ -1,24 +0,0 @@
#nullable enable
#pragma warning disable CS1591
using System.Collections.Generic;
using Emby.Dlna.Configuration;
using MediaBrowser.Common.Configuration;
namespace Emby.Dlna
{
public class DlnaConfigurationFactory : IConfigurationFactory
{
public IEnumerable<ConfigurationStore> GetConfigurations()
{
return new[]
{
new ConfigurationStore
{
Key = "dlna",
ConfigurationType = typeof(DlnaOptions)
}
};
}
}
}
+52 -49
View File
@@ -54,15 +54,11 @@ namespace Emby.Dlna
_appHost = appHost; _appHost = appHost;
} }
private string UserProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user");
private string SystemProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system");
public async Task InitProfilesAsync() public async Task InitProfilesAsync()
{ {
try try
{ {
await ExtractSystemProfilesAsync().ConfigureAwait(false); await ExtractSystemProfilesAsync();
LoadProfiles(); LoadProfiles();
} }
catch (Exception ex) catch (Exception ex)
@@ -126,23 +122,32 @@ namespace Emby.Dlna
var builder = new StringBuilder(); var builder = new StringBuilder();
builder.AppendLine("No matching device profile found. The default will need to be used."); builder.AppendLine("No matching device profile found. The default will need to be used.");
builder.Append("FriendlyName:").AppendLine(profile.FriendlyName); builder.AppendLine(string.Format("DeviceDescription:{0}", profile.DeviceDescription ?? string.Empty));
builder.Append("Manufacturer:").AppendLine(profile.Manufacturer); builder.AppendLine(string.Format("FriendlyName:{0}", profile.FriendlyName ?? string.Empty));
builder.Append("ManufacturerUrl:").AppendLine(profile.ManufacturerUrl); builder.AppendLine(string.Format("Manufacturer:{0}", profile.Manufacturer ?? string.Empty));
builder.Append("ModelDescription:").AppendLine(profile.ModelDescription); builder.AppendLine(string.Format("ManufacturerUrl:{0}", profile.ManufacturerUrl ?? string.Empty));
builder.Append("ModelName:").AppendLine(profile.ModelName); builder.AppendLine(string.Format("ModelDescription:{0}", profile.ModelDescription ?? string.Empty));
builder.Append("ModelNumber:").AppendLine(profile.ModelNumber); builder.AppendLine(string.Format("ModelName:{0}", profile.ModelName ?? string.Empty));
builder.Append("ModelUrl:").AppendLine(profile.ModelUrl); builder.AppendLine(string.Format("ModelNumber:{0}", profile.ModelNumber ?? string.Empty));
builder.Append("SerialNumber:").AppendLine(profile.SerialNumber); builder.AppendLine(string.Format("ModelUrl:{0}", profile.ModelUrl ?? string.Empty));
builder.AppendLine(string.Format("SerialNumber:{0}", profile.SerialNumber ?? string.Empty));
_logger.LogInformation(builder.ToString()); _logger.LogInformation(builder.ToString());
} }
private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo) private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
{ {
if (!string.IsNullOrEmpty(profileInfo.DeviceDescription))
{
if (deviceInfo.DeviceDescription == null || !IsRegexMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription))
{
return false;
}
}
if (!string.IsNullOrEmpty(profileInfo.FriendlyName)) if (!string.IsNullOrEmpty(profileInfo.FriendlyName))
{ {
if (deviceInfo.FriendlyName == null || !IsRegexOrSubstringMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)) if (deviceInfo.FriendlyName == null || !IsRegexMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName))
{ {
return false; return false;
} }
@@ -150,7 +155,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.Manufacturer)) if (!string.IsNullOrEmpty(profileInfo.Manufacturer))
{ {
if (deviceInfo.Manufacturer == null || !IsRegexOrSubstringMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)) if (deviceInfo.Manufacturer == null || !IsRegexMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer))
{ {
return false; return false;
} }
@@ -158,7 +163,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.ManufacturerUrl)) if (!string.IsNullOrEmpty(profileInfo.ManufacturerUrl))
{ {
if (deviceInfo.ManufacturerUrl == null || !IsRegexOrSubstringMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)) if (deviceInfo.ManufacturerUrl == null || !IsRegexMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl))
{ {
return false; return false;
} }
@@ -166,7 +171,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.ModelDescription)) if (!string.IsNullOrEmpty(profileInfo.ModelDescription))
{ {
if (deviceInfo.ModelDescription == null || !IsRegexOrSubstringMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)) if (deviceInfo.ModelDescription == null || !IsRegexMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription))
{ {
return false; return false;
} }
@@ -174,7 +179,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.ModelName)) if (!string.IsNullOrEmpty(profileInfo.ModelName))
{ {
if (deviceInfo.ModelName == null || !IsRegexOrSubstringMatch(deviceInfo.ModelName, profileInfo.ModelName)) if (deviceInfo.ModelName == null || !IsRegexMatch(deviceInfo.ModelName, profileInfo.ModelName))
{ {
return false; return false;
} }
@@ -182,7 +187,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.ModelNumber)) if (!string.IsNullOrEmpty(profileInfo.ModelNumber))
{ {
if (deviceInfo.ModelNumber == null || !IsRegexOrSubstringMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)) if (deviceInfo.ModelNumber == null || !IsRegexMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber))
{ {
return false; return false;
} }
@@ -190,7 +195,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.ModelUrl)) if (!string.IsNullOrEmpty(profileInfo.ModelUrl))
{ {
if (deviceInfo.ModelUrl == null || !IsRegexOrSubstringMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)) if (deviceInfo.ModelUrl == null || !IsRegexMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl))
{ {
return false; return false;
} }
@@ -198,7 +203,7 @@ namespace Emby.Dlna
if (!string.IsNullOrEmpty(profileInfo.SerialNumber)) if (!string.IsNullOrEmpty(profileInfo.SerialNumber))
{ {
if (deviceInfo.SerialNumber == null || !IsRegexOrSubstringMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber)) if (deviceInfo.SerialNumber == null || !IsRegexMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber))
{ {
return false; return false;
} }
@@ -207,11 +212,11 @@ namespace Emby.Dlna
return true; return true;
} }
private bool IsRegexOrSubstringMatch(string input, string pattern) private bool IsRegexMatch(string input, string pattern)
{ {
try try
{ {
return input.Contains(pattern, StringComparison.OrdinalIgnoreCase) || Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); return Regex.IsMatch(input, pattern);
} }
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
@@ -235,7 +240,7 @@ namespace Emby.Dlna
} }
else else
{ {
var headerString = string.Join(", ", headers.Select(i => string.Format(CultureInfo.InvariantCulture, "{0}={1}", i.Key, i.Value))); var headerString = string.Join(", ", headers.Select(i => string.Format("{0}={1}", i.Key, i.Value)).ToArray());
_logger.LogDebug("No matching device profile found. {0}", headerString); _logger.LogDebug("No matching device profile found. {0}", headerString);
} }
@@ -275,6 +280,10 @@ namespace Emby.Dlna
return false; return false;
} }
private string UserProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "user");
private string SystemProfilesPath => Path.Combine(_appPaths.ConfigurationDirectoryPath, "dlna", "system");
private IEnumerable<DeviceProfile> GetProfiles(string path, DeviceProfileType type) private IEnumerable<DeviceProfile> GetProfiles(string path, DeviceProfileType type)
{ {
try try
@@ -333,12 +342,7 @@ namespace Emby.Dlna
throw new ArgumentNullException(nameof(id)); throw new ArgumentNullException(nameof(id));
} }
var info = GetProfileInfosInternal().FirstOrDefault(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase)); var info = GetProfileInfosInternal().First(i => string.Equals(i.Info.Id, id, StringComparison.OrdinalIgnoreCase));
if (info == null)
{
return null;
}
return ParseProfileFile(info.Path, info.Info.Type); return ParseProfileFile(info.Path, info.Info.Type);
} }
@@ -383,14 +387,14 @@ namespace Emby.Dlna
foreach (var name in _assembly.GetManifestResourceNames()) foreach (var name in _assembly.GetManifestResourceNames())
{ {
if (!name.StartsWith(namespaceName, StringComparison.Ordinal)) if (!name.StartsWith(namespaceName))
{ {
continue; continue;
} }
var path = Path.Join( var filename = Path.GetFileName(name).Substring(namespaceName.Length);
systemProfilesPath,
Path.GetFileName(name.AsSpan()).Slice(namespaceName.Length)); var path = Path.Combine(systemProfilesPath, filename);
using (var stream = _assembly.GetManifestResourceStream(name)) using (var stream = _assembly.GetManifestResourceStream(name))
{ {
@@ -400,10 +404,9 @@ namespace Emby.Dlna
{ {
Directory.CreateDirectory(systemProfilesPath); Directory.CreateDirectory(systemProfilesPath);
// use FileShare.None as this bypasses dotnet bug dotnet/runtime#42790 . using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
{ {
await stream.CopyToAsync(fileStream).ConfigureAwait(false); await stream.CopyToAsync(fileStream);
} }
} }
} }
@@ -490,10 +493,10 @@ namespace Emby.Dlna
/// <summary> /// <summary>
/// Recreates the object using serialization, to ensure it's not a subclass. /// Recreates the object using serialization, to ensure it's not a subclass.
/// If it's a subclass it may not serialize properly to xml (different root element tag name). /// If it's a subclass it may not serlialize properly to xml (different root element tag name).
/// </summary> /// </summary>
/// <param name="profile">The device profile.</param> /// <param name="profile"></param>
/// <returns>The re-serialized device profile.</returns> /// <returns></returns>
private DeviceProfile ReserializeProfile(DeviceProfile profile) private DeviceProfile ReserializeProfile(DeviceProfile profile)
{ {
if (profile.GetType() == typeof(DeviceProfile)) if (profile.GetType() == typeof(DeviceProfile))
@@ -506,9 +509,17 @@ namespace Emby.Dlna
return _jsonSerializer.DeserializeFromString<DeviceProfile>(json); return _jsonSerializer.DeserializeFromString<DeviceProfile>(json);
} }
class InternalProfileInfo
{
internal DeviceProfileInfo Info { get; set; }
internal string Path { get; set; }
}
public string GetServerDescriptionXml(IHeaderDictionary headers, string serverUuId, string serverAddress) public string GetServerDescriptionXml(IHeaderDictionary headers, string serverUuId, string serverAddress)
{ {
var profile = GetDefaultProfile(); var profile = GetProfile(headers) ??
GetDefaultProfile();
var serverId = _appHost.SystemId; var serverId = _appHost.SystemId;
@@ -529,15 +540,7 @@ namespace Emby.Dlna
Stream = _assembly.GetManifestResourceStream(resource) Stream = _assembly.GetManifestResourceStream(resource)
}; };
} }
private class InternalProfileInfo
{
internal DeviceProfileInfo Info { get; set; }
internal string Path { get; set; }
}
} }
/* /*
class DlnaProfileEntryPoint : IServerEntryPoint class DlnaProfileEntryPoint : IServerEntryPoint
{ {
+2 -3
View File
@@ -17,10 +17,10 @@
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>netstandard2.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release'" >true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<!-- Code Analyzers--> <!-- Code Analyzers-->
@@ -80,7 +80,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" /> <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.6" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+1 -1
View File
@@ -15,6 +15,6 @@ namespace Emby.Dlna
public string ContentType { get; set; } public string ContentType { get; set; }
public Dictionary<string, string> Headers { get; } public Dictionary<string, string> Headers { get; set; }
} }
} }
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Net.Mime;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
@@ -15,19 +14,17 @@ using Microsoft.Extensions.Logging;
namespace Emby.Dlna.Eventing namespace Emby.Dlna.Eventing
{ {
public class DlnaEventManager : IDlnaEventManager public class EventManager : IEventManager
{ {
private readonly ConcurrentDictionary<string, EventSubscription> _subscriptions = private readonly ConcurrentDictionary<string, EventSubscription> _subscriptions =
new ConcurrentDictionary<string, EventSubscription>(StringComparer.OrdinalIgnoreCase); new ConcurrentDictionary<string, EventSubscription>(StringComparer.OrdinalIgnoreCase);
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClient _httpClient;
private readonly CultureInfo _usCulture = new CultureInfo("en-US"); public EventManager(ILogger logger, IHttpClient httpClient)
public DlnaEventManager(ILogger logger, IHttpClientFactory httpClientFactory)
{ {
_httpClientFactory = httpClientFactory; _httpClient = httpClient;
_logger = logger; _logger = logger;
} }
@@ -61,8 +58,7 @@ namespace Emby.Dlna.Eventing
var timeout = ParseTimeout(requestedTimeoutString) ?? 300; var timeout = ParseTimeout(requestedTimeoutString) ?? 300;
var id = "uuid:" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture); var id = "uuid:" + Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
_logger.LogDebug( _logger.LogDebug("Creating event subscription for {0} with timeout of {1} to {2}",
"Creating event subscription for {0} with timeout of {1} to {2}",
notificationType, notificationType,
timeout, timeout,
callbackUrl); callbackUrl);
@@ -72,8 +68,7 @@ namespace Emby.Dlna.Eventing
Id = id, Id = id,
CallbackUrl = callbackUrl, CallbackUrl = callbackUrl,
SubscriptionTime = DateTime.UtcNow, SubscriptionTime = DateTime.UtcNow,
TimeoutSeconds = timeout, TimeoutSeconds = timeout
NotificationType = notificationType
}); });
return GetEventSubscriptionResponse(id, requestedTimeoutString, timeout); return GetEventSubscriptionResponse(id, requestedTimeoutString, timeout);
@@ -84,7 +79,7 @@ namespace Emby.Dlna.Eventing
if (!string.IsNullOrEmpty(header)) if (!string.IsNullOrEmpty(header))
{ {
// Starts with SECOND- // Starts with SECOND-
header = header.Split('-')[^1]; header = header.Split('-').Last();
if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val)) if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val))
{ {
@@ -99,7 +94,7 @@ namespace Emby.Dlna.Eventing
{ {
_logger.LogDebug("Cancelling event subscription {0}", subscriptionId); _logger.LogDebug("Cancelling event subscription {0}", subscriptionId);
_subscriptions.TryRemove(subscriptionId, out _); _subscriptions.TryRemove(subscriptionId, out EventSubscription sub);
return new EventSubscriptionResponse return new EventSubscriptionResponse
{ {
@@ -108,6 +103,7 @@ namespace Emby.Dlna.Eventing
}; };
} }
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
private EventSubscriptionResponse GetEventSubscriptionResponse(string subscriptionId, string requestedTimeoutString, int timeoutSeconds) private EventSubscriptionResponse GetEventSubscriptionResponse(string subscriptionId, string requestedTimeoutString, int timeoutSeconds)
{ {
var response = new EventSubscriptionResponse var response = new EventSubscriptionResponse
@@ -156,30 +152,33 @@ namespace Emby.Dlna.Eventing
builder.Append("<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">"); builder.Append("<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">");
foreach (var key in stateVariables.Keys) foreach (var key in stateVariables.Keys)
{ {
builder.Append("<e:property>") builder.Append("<e:property>");
.Append('<') builder.Append("<" + key + ">");
.Append(key) builder.Append(stateVariables[key]);
.Append('>') builder.Append("</" + key + ">");
.Append(stateVariables[key]) builder.Append("</e:property>");
.Append("</")
.Append(key)
.Append('>')
.Append("</e:property>");
} }
builder.Append("</e:propertyset>"); builder.Append("</e:propertyset>");
using var options = new HttpRequestMessage(new HttpMethod("NOTIFY"), subscription.CallbackUrl); var options = new HttpRequestOptions
options.Content = new StringContent(builder.ToString(), Encoding.UTF8, MediaTypeNames.Text.Xml); {
options.Headers.TryAddWithoutValidation("NT", subscription.NotificationType); RequestContent = builder.ToString(),
options.Headers.TryAddWithoutValidation("NTS", "upnp:propchange"); RequestContentType = "text/xml",
options.Headers.TryAddWithoutValidation("SID", subscription.Id); Url = subscription.CallbackUrl,
options.Headers.TryAddWithoutValidation("SEQ", subscription.TriggerCount.ToString(_usCulture)); BufferContent = false
};
options.RequestHeaders.Add("NT", subscription.NotificationType);
options.RequestHeaders.Add("NTS", "upnp:propchange");
options.RequestHeaders.Add("SID", subscription.Id);
options.RequestHeaders.Add("SEQ", subscription.TriggerCount.ToString(_usCulture));
try try
{ {
using var response = await _httpClientFactory.CreateClient(NamedClient.Default) using (await _httpClient.SendAsync(options, new HttpMethod("NOTIFY")).ConfigureAwait(false))
.SendAsync(options, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); {
}
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Emby.Dlna namespace Emby.Dlna
{ {
public interface IConnectionManager : IDlnaEventManager, IUpnpService public interface IConnectionManager : IEventManager, IUpnpService
{ {
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Emby.Dlna namespace Emby.Dlna
{ {
public interface IContentDirectory : IDlnaEventManager, IUpnpService public interface IContentDirectory : IEventManager, IUpnpService
{ {
} }
} }
@@ -2,32 +2,22 @@
namespace Emby.Dlna namespace Emby.Dlna
{ {
public interface IDlnaEventManager public interface IEventManager
{ {
/// <summary> /// <summary>
/// Cancels the event subscription. /// Cancels the event subscription.
/// </summary> /// </summary>
/// <param name="subscriptionId">The subscription identifier.</param> /// <param name="subscriptionId">The subscription identifier.</param>
/// <returns>The response.</returns>
EventSubscriptionResponse CancelEventSubscription(string subscriptionId); EventSubscriptionResponse CancelEventSubscription(string subscriptionId);
/// <summary> /// <summary>
/// Renews the event subscription. /// Renews the event subscription.
/// </summary> /// </summary>
/// <param name="subscriptionId">The subscription identifier.</param>
/// <param name="notificationType">The notification type.</param>
/// <param name="requestedTimeoutString">The requested timeout as a sting.</param>
/// <param name="callbackUrl">The callback url.</param>
/// <returns>The response.</returns>
EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl); EventSubscriptionResponse RenewEventSubscription(string subscriptionId, string notificationType, string requestedTimeoutString, string callbackUrl);
/// <summary> /// <summary>
/// Creates the event subscription. /// Creates the event subscription.
/// </summary> /// </summary>
/// <param name="notificationType">The notification type.</param>
/// <param name="requestedTimeoutString">The requested timeout as a sting.</param>
/// <param name="callbackUrl">The callback url.</param>
/// <returns>The response.</returns>
EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl); EventSubscriptionResponse CreateEventSubscription(string notificationType, string requestedTimeoutString, string callbackUrl);
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Emby.Dlna namespace Emby.Dlna
{ {
public interface IMediaReceiverRegistrar : IDlnaEventManager, IUpnpService public interface IMediaReceiverRegistrar : IEventManager, IUpnpService
{ {
} }
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 286 B

+48 -101
View File
@@ -2,15 +2,11 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.Dlna.PlayTo; using Emby.Dlna.PlayTo;
using Emby.Dlna.Ssdp; using Emby.Dlna.Ssdp;
using Jellyfin.Networking.Configuration;
using Jellyfin.Networking.Manager;
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
@@ -34,13 +30,13 @@ using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
namespace Emby.Dlna.Main namespace Emby.Dlna.Main
{ {
public sealed class DlnaEntryPoint : IServerEntryPoint, IRunBeforeStartup public class DlnaEntryPoint : IServerEntryPoint, IRunBeforeStartup
{ {
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly ILogger<DlnaEntryPoint> _logger; private readonly ILogger<DlnaEntryPoint> _logger;
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClient _httpClient;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IDlnaManager _dlnaManager; private readonly IDlnaManager _dlnaManager;
@@ -53,21 +49,25 @@ namespace Emby.Dlna.Main
private readonly ISocketFactory _socketFactory; private readonly ISocketFactory _socketFactory;
private readonly INetworkManager _networkManager; private readonly INetworkManager _networkManager;
private readonly object _syncLock = new object(); private readonly object _syncLock = new object();
private readonly NetworkConfiguration _netConfig;
private readonly bool _disabled;
private PlayToManager _manager; private PlayToManager _manager;
private SsdpDevicePublisher _publisher; private SsdpDevicePublisher _publisher;
private ISsdpCommunicationsServer _communicationsServer; private ISsdpCommunicationsServer _communicationsServer;
private bool _disposed; internal IContentDirectory ContentDirectory { get; private set; }
internal IConnectionManager ConnectionManager { get; private set; }
internal IMediaReceiverRegistrar MediaReceiverRegistrar { get; private set; }
public static DlnaEntryPoint Current;
public DlnaEntryPoint( public DlnaEntryPoint(
IServerConfigurationManager config, IServerConfigurationManager config,
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IServerApplicationHost appHost, IServerApplicationHost appHost,
ISessionManager sessionManager, ISessionManager sessionManager,
IHttpClientFactory httpClientFactory, IHttpClient httpClient,
ILibraryManager libraryManager, ILibraryManager libraryManager,
IUserManager userManager, IUserManager userManager,
IDlnaManager dlnaManager, IDlnaManager dlnaManager,
@@ -85,7 +85,7 @@ namespace Emby.Dlna.Main
_config = config; _config = config;
_appHost = appHost; _appHost = appHost;
_sessionManager = sessionManager; _sessionManager = sessionManager;
_httpClientFactory = httpClientFactory; _httpClient = httpClient;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_userManager = userManager; _userManager = userManager;
_dlnaManager = dlnaManager; _dlnaManager = dlnaManager;
@@ -99,88 +99,60 @@ namespace Emby.Dlna.Main
_networkManager = networkManager; _networkManager = networkManager;
_logger = loggerFactory.CreateLogger<DlnaEntryPoint>(); _logger = loggerFactory.CreateLogger<DlnaEntryPoint>();
ContentDirectory = new ContentDirectory.ContentDirectoryService( ContentDirectory = new ContentDirectory.ContentDirectory(
dlnaManager, dlnaManager,
userDataManager, userDataManager,
imageProcessor, imageProcessor,
libraryManager, libraryManager,
config, config,
userManager, userManager,
loggerFactory.CreateLogger<ContentDirectory.ContentDirectoryService>(), loggerFactory.CreateLogger<ContentDirectory.ContentDirectory>(),
httpClientFactory, httpClient,
localizationManager, localizationManager,
mediaSourceManager, mediaSourceManager,
userViewManager, userViewManager,
mediaEncoder, mediaEncoder,
tvSeriesManager); tvSeriesManager);
ConnectionManager = new ConnectionManager.ConnectionManagerService( ConnectionManager = new ConnectionManager.ConnectionManager(
dlnaManager, dlnaManager,
config, config,
loggerFactory.CreateLogger<ConnectionManager.ConnectionManagerService>(), loggerFactory.CreateLogger<ConnectionManager.ConnectionManager>(),
httpClientFactory); httpClient);
MediaReceiverRegistrar = new MediaReceiverRegistrar.MediaReceiverRegistrarService( MediaReceiverRegistrar = new MediaReceiverRegistrar.MediaReceiverRegistrar(
loggerFactory.CreateLogger<MediaReceiverRegistrar.MediaReceiverRegistrarService>(), loggerFactory.CreateLogger<MediaReceiverRegistrar.MediaReceiverRegistrar>(),
httpClientFactory, httpClient,
config); config);
Current = this; Current = this;
_netConfig = config.GetConfiguration<NetworkConfiguration>("network");
_disabled = appHost.ListenWithHttps && _netConfig.RequireHttps;
if (_disabled && _config.GetDlnaConfiguration().EnableServer)
{
_logger.LogError("The DLNA specification does not support HTTPS.");
}
} }
public static DlnaEntryPoint Current { get; private set; }
/// <summary>
/// Gets a value indicating whether the dlna server is enabled.
/// </summary>
public static bool Enabled { get; private set; }
public IContentDirectory ContentDirectory { get; private set; }
public IConnectionManager ConnectionManager { get; private set; }
public IMediaReceiverRegistrar MediaReceiverRegistrar { get; private set; }
public async Task RunAsync() public async Task RunAsync()
{ {
await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false); await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);
if (_disabled) await ReloadComponents().ConfigureAwait(false);
{
// No use starting as dlna won't work, as we're running purely on HTTPS.
return;
}
ReloadComponents();
_config.NamedConfigurationUpdated += OnNamedConfigurationUpdated; _config.NamedConfigurationUpdated += OnNamedConfigurationUpdated;
} }
private void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e) private async void OnNamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
{ {
if (string.Equals(e.Key, "dlna", StringComparison.OrdinalIgnoreCase)) if (string.Equals(e.Key, "dlna", StringComparison.OrdinalIgnoreCase))
{ {
ReloadComponents(); await ReloadComponents().ConfigureAwait(false);
} }
} }
private void ReloadComponents() private async Task ReloadComponents()
{ {
var options = _config.GetDlnaConfiguration(); var options = _config.GetDlnaConfiguration();
Enabled = options.EnableServer;
StartSsdpHandler(); StartSsdpHandler();
if (options.EnableServer) if (options.EnableServer)
{ {
StartDevicePublisher(options); await StartDevicePublisher(options).ConfigureAwait(false);
} }
else else
{ {
@@ -229,10 +201,7 @@ namespace Emby.Dlna.Main
{ {
try try
{ {
if (communicationsServer != null) ((DeviceDiscovery)_deviceDiscovery).Start(communicationsServer);
{
((DeviceDiscovery)_deviceDiscovery).Start(communicationsServer);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -253,7 +222,7 @@ namespace Emby.Dlna.Main
} }
} }
public void StartDevicePublisher(Configuration.DlnaOptions options) public async Task StartDevicePublisher(Configuration.DlnaOptions options)
{ {
if (!options.BlastAliveMessages) if (!options.BlastAliveMessages)
{ {
@@ -273,7 +242,7 @@ namespace Emby.Dlna.Main
SupportPnpRootDevice = false SupportPnpRootDevice = false
}; };
RegisterServerEndpoints(); await RegisterServerEndpoints().ConfigureAwait(false);
_publisher.StartBroadcastingAliveMessages(TimeSpan.FromSeconds(options.BlastAliveMessageIntervalSeconds)); _publisher.StartBroadcastingAliveMessages(TimeSpan.FromSeconds(options.BlastAliveMessageIntervalSeconds));
} }
@@ -283,22 +252,13 @@ namespace Emby.Dlna.Main
} }
} }
private void RegisterServerEndpoints() private async Task RegisterServerEndpoints()
{ {
var addresses = await _appHost.GetLocalIpAddresses(CancellationToken.None).ConfigureAwait(false);
var udn = CreateUuid(_appHost.SystemId); var udn = CreateUuid(_appHost.SystemId);
var descriptorUri = "/dlna/" + udn + "/description.xml";
var bindAddresses = NetworkManager.CreateCollection( foreach (var address in addresses)
_networkManager.GetInternalBindAddresses()
.Where(i => i.AddressFamily == AddressFamily.InterNetwork || (i.AddressFamily == AddressFamily.InterNetworkV6 && i.Address.ScopeId != 0)));
if (bindAddresses.Count == 0)
{
// No interfaces returned, so use loopback.
bindAddresses = _networkManager.GetLoopbacks();
}
foreach (IPNetAddress address in bindAddresses)
{ {
if (address.AddressFamily == AddressFamily.InterNetworkV6) if (address.AddressFamily == AddressFamily.InterNetworkV6)
{ {
@@ -307,7 +267,7 @@ namespace Emby.Dlna.Main
} }
// Limit to LAN addresses only // Limit to LAN addresses only
if (!_networkManager.IsInLocalNetwork(address)) if (!_networkManager.IsAddressInSubnets(address, true, true))
{ {
continue; continue;
} }
@@ -316,20 +276,15 @@ namespace Emby.Dlna.Main
_logger.LogInformation("Registering publisher for {0} on {1}", fullService, address); _logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);
var uri = new UriBuilder(_appHost.GetSmartApiUrl(address.Address) + descriptorUri); var descriptorUri = "/dlna/" + udn + "/description.xml";
if (!string.IsNullOrEmpty(_appHost.PublishedServerUrl)) var uri = new Uri(_appHost.GetLocalApiUrl(address) + descriptorUri);
{
// DLNA will only work over http, so we must reset to http:// : {port}.
uri.Scheme = "http";
uri.Port = _netConfig.HttpServerPortNumber;
}
var device = new SsdpRootDevice var device = new SsdpRootDevice
{ {
CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info. CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info.
Location = uri.Uri, // Must point to the URL that serves your devices UPnP description document. Location = uri, // Must point to the URL that serves your devices UPnP description document.
Address = address.Address, Address = address,
PrefixLength = address.PrefixLength, SubnetMask = _networkManager.GetLocalIpSubnetMask(address),
FriendlyName = "Jellyfin", FriendlyName = "Jellyfin",
Manufacturer = "Jellyfin", Manufacturer = "Jellyfin",
ModelName = "Jellyfin Server", ModelName = "Jellyfin Server",
@@ -407,7 +362,7 @@ namespace Emby.Dlna.Main
_appHost, _appHost,
_imageProcessor, _imageProcessor,
_deviceDiscovery, _deviceDiscovery,
_httpClientFactory, _httpClient,
_config, _config,
_userDataManager, _userDataManager,
_localization, _localization,
@@ -444,24 +399,8 @@ namespace Emby.Dlna.Main
} }
} }
public void DisposeDevicePublisher()
{
if (_publisher != null)
{
_logger.LogInformation("Disposing SsdpDevicePublisher");
_publisher.Dispose();
_publisher = null;
}
}
/// <inheritdoc />
public void Dispose() public void Dispose()
{ {
if (_disposed)
{
return;
}
DisposeDevicePublisher(); DisposeDevicePublisher();
DisposePlayToManager(); DisposePlayToManager();
DisposeDeviceDiscovery(); DisposeDeviceDiscovery();
@@ -477,8 +416,16 @@ namespace Emby.Dlna.Main
ConnectionManager = null; ConnectionManager = null;
MediaReceiverRegistrar = null; MediaReceiverRegistrar = null;
Current = null; Current = null;
}
_disposed = true; public void DisposeDevicePublisher()
{
if (_publisher != null)
{
_logger.LogInformation("Disposing SsdpDevicePublisher");
_publisher.Dispose();
_publisher = null;
}
} }
} }
} }
@@ -1,3 +1,5 @@
#pragma warning disable CS1591
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml; using System.Xml;
@@ -8,16 +10,8 @@ using Microsoft.Extensions.Logging;
namespace Emby.Dlna.MediaReceiverRegistrar namespace Emby.Dlna.MediaReceiverRegistrar
{ {
/// <summary>
/// Defines the <see cref="ControlHandler" />.
/// </summary>
public class ControlHandler : BaseControlHandler public class ControlHandler : BaseControlHandler
{ {
/// <summary>
/// Initializes a new instance of the <see cref="ControlHandler"/> class.
/// </summary>
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
/// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
public ControlHandler(IServerConfigurationManager config, ILogger logger) public ControlHandler(IServerConfigurationManager config, ILogger logger)
: base(config, logger) : base(config, logger)
{ {
@@ -41,17 +35,9 @@ namespace Emby.Dlna.MediaReceiverRegistrar
throw new ResourceNotFoundException("Unexpected control request name: " + methodName); throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
} }
/// <summary>
/// Records that the handle is authorized in the xml stream.
/// </summary>
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
private static void HandleIsAuthorized(XmlWriter xmlWriter) private static void HandleIsAuthorized(XmlWriter xmlWriter)
=> xmlWriter.WriteElementString("Result", "1"); => xmlWriter.WriteElementString("Result", "1");
/// <summary>
/// Records that the handle is validated in the xml stream.
/// </summary>
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
private static void HandleIsValidated(XmlWriter xmlWriter) private static void HandleIsValidated(XmlWriter xmlWriter)
=> xmlWriter.WriteElementString("Result", "1"); => xmlWriter.WriteElementString("Result", "1");
} }
@@ -0,0 +1,39 @@
#pragma warning disable CS1591
using System.Threading.Tasks;
using Emby.Dlna.Service;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using Microsoft.Extensions.Logging;
namespace Emby.Dlna.MediaReceiverRegistrar
{
public class MediaReceiverRegistrar : BaseService, IMediaReceiverRegistrar
{
private readonly IServerConfigurationManager _config;
public MediaReceiverRegistrar(
ILogger<MediaReceiverRegistrar> logger,
IHttpClient httpClient,
IServerConfigurationManager config)
: base(logger, httpClient)
{
_config = config;
}
/// <inheritdoc />
public string GetServiceXml()
{
return new MediaReceiverRegistrarXmlBuilder().GetXml();
}
/// <inheritdoc />
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
{
return new ControlHandler(
_config,
Logger)
.ProcessControlRequestAsync(request);
}
}
}
@@ -1,46 +0,0 @@
using System.Net.Http;
using System.Threading.Tasks;
using Emby.Dlna.Service;
using MediaBrowser.Controller.Configuration;
using Microsoft.Extensions.Logging;
namespace Emby.Dlna.MediaReceiverRegistrar
{
/// <summary>
/// Defines the <see cref="MediaReceiverRegistrarService" />.
/// </summary>
public class MediaReceiverRegistrarService : BaseService, IMediaReceiverRegistrar
{
private readonly IServerConfigurationManager _config;
/// <summary>
/// Initializes a new instance of the <see cref="MediaReceiverRegistrarService"/> class.
/// </summary>
/// <param name="logger">The <see cref="ILogger{MediaReceiverRegistrarService}"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="MediaReceiverRegistrarService"/> instance.</param>
public MediaReceiverRegistrarService(
ILogger<MediaReceiverRegistrarService> logger,
IHttpClientFactory httpClientFactory,
IServerConfigurationManager config)
: base(logger, httpClientFactory)
{
_config = config;
}
/// <inheritdoc />
public string GetServiceXml()
{
return MediaReceiverRegistrarXmlBuilder.GetXml();
}
/// <inheritdoc />
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
{
return new ControlHandler(
_config,
Logger)
.ProcessControlRequestAsync(request);
}
}
}
@@ -1,89 +1,78 @@
#pragma warning disable CS1591
using System.Collections.Generic; using System.Collections.Generic;
using Emby.Dlna.Common; using Emby.Dlna.Common;
using Emby.Dlna.Service; using Emby.Dlna.Service;
using MediaBrowser.Model.Dlna;
namespace Emby.Dlna.MediaReceiverRegistrar namespace Emby.Dlna.MediaReceiverRegistrar
{ {
/// <summary> public class MediaReceiverRegistrarXmlBuilder
/// Defines the <see cref="MediaReceiverRegistrarXmlBuilder" />.
/// See https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-drmnd/5d37515e-7a63-4709-8258-8fd4e0ed4482.
/// </summary>
public static class MediaReceiverRegistrarXmlBuilder
{ {
/// <summary> public string GetXml()
/// Retrieves an XML description of the X_MS_MediaReceiverRegistrar.
/// </summary>
/// <returns>An XML representation of this service.</returns>
public static string GetXml()
{ {
return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables()); return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(),
GetStateVariables());
} }
/// <summary>
/// The a list of all the state variables for this invocation.
/// </summary>
/// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
private static IEnumerable<StateVariable> GetStateVariables() private static IEnumerable<StateVariable> GetStateVariables()
{ {
var list = new List<StateVariable> var list = new List<StateVariable>();
list.Add(new StateVariable
{ {
new StateVariable Name = "AuthorizationGrantedUpdateID",
{ DataType = "ui4",
Name = "AuthorizationGrantedUpdateID", SendsEvents = true
DataType = "ui4", });
SendsEvents = true
},
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_DeviceID", Name = "A_ARG_TYPE_DeviceID",
DataType = "string", DataType = "string",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "AuthorizationDeniedUpdateID", Name = "AuthorizationDeniedUpdateID",
DataType = "ui4", DataType = "ui4",
SendsEvents = true SendsEvents = true
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "ValidationSucceededUpdateID", Name = "ValidationSucceededUpdateID",
DataType = "ui4", DataType = "ui4",
SendsEvents = true SendsEvents = true
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_RegistrationRespMsg", Name = "A_ARG_TYPE_RegistrationRespMsg",
DataType = "bin.base64", DataType = "bin.base64",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_RegistrationReqMsg", Name = "A_ARG_TYPE_RegistrationReqMsg",
DataType = "bin.base64", DataType = "bin.base64",
SendsEvents = false SendsEvents = false
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "ValidationRevokedUpdateID", Name = "ValidationRevokedUpdateID",
DataType = "ui4", DataType = "ui4",
SendsEvents = true SendsEvents = true
}, });
new StateVariable list.Add(new StateVariable
{ {
Name = "A_ARG_TYPE_Result", Name = "A_ARG_TYPE_Result",
DataType = "int", DataType = "int",
SendsEvents = false SendsEvents = false
} });
};
return list; return list;
} }
@@ -1,18 +1,13 @@
#pragma warning disable CS1591
using System.Collections.Generic; using System.Collections.Generic;
using Emby.Dlna.Common; using Emby.Dlna.Common;
namespace Emby.Dlna.MediaReceiverRegistrar namespace Emby.Dlna.MediaReceiverRegistrar
{ {
/// <summary> public class ServiceActionListBuilder
/// Defines the <see cref="ServiceActionListBuilder" />.
/// </summary>
public static class ServiceActionListBuilder
{ {
/// <summary> public IEnumerable<ServiceAction> GetActions()
/// Returns a list of services that this instance provides.
/// </summary>
/// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
public static IEnumerable<ServiceAction> GetActions()
{ {
return new[] return new[]
{ {
@@ -26,10 +21,6 @@ namespace Emby.Dlna.MediaReceiverRegistrar
}; };
} }
/// <summary>
/// Returns the action details for "IsValidated".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetIsValidated() private static ServiceAction GetIsValidated()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -52,10 +43,6 @@ namespace Emby.Dlna.MediaReceiverRegistrar
return action; return action;
} }
/// <summary>
/// Returns the action details for "IsAuthorized".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetIsAuthorized() private static ServiceAction GetIsAuthorized()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -78,10 +65,6 @@ namespace Emby.Dlna.MediaReceiverRegistrar
return action; return action;
} }
/// <summary>
/// Returns the action details for "RegisterDevice".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetRegisterDevice() private static ServiceAction GetRegisterDevice()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -104,10 +87,6 @@ namespace Emby.Dlna.MediaReceiverRegistrar
return action; return action;
} }
/// <summary>
/// Returns the action details for "GetValidationSucceededUpdateID".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetGetValidationSucceededUpdateID() private static ServiceAction GetGetValidationSucceededUpdateID()
{ {
var action = new ServiceAction var action = new ServiceAction
@@ -124,11 +103,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar
return action; return action;
} }
/// <summary> private ServiceAction GetGetAuthorizationDeniedUpdateID()
/// Returns the action details for "GetGetAuthorizationDeniedUpdateID".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetGetAuthorizationDeniedUpdateID()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -144,11 +119,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar
return action; return action;
} }
/// <summary> private ServiceAction GetGetValidationRevokedUpdateID()
/// Returns the action details for "GetValidationRevokedUpdateID".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetGetValidationRevokedUpdateID()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
@@ -164,11 +135,7 @@ namespace Emby.Dlna.MediaReceiverRegistrar
return action; return action;
} }
/// <summary> private ServiceAction GetGetAuthorizationGrantedUpdateID()
/// Returns the action details for "GetAuthorizationGrantedUpdateID".
/// </summary>
/// <returns>The <see cref="ServiceAction"/>.</returns>
private static ServiceAction GetGetAuthorizationGrantedUpdateID()
{ {
var action = new ServiceAction var action = new ServiceAction
{ {
+141 -172
View File
@@ -4,54 +4,30 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Security;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml; using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using Emby.Dlna.Common; using Emby.Dlna.Common;
using Emby.Dlna.Server;
using Emby.Dlna.Ssdp; using Emby.Dlna.Ssdp;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
public class Device : IDisposable public class Device : IDisposable
{ {
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
private readonly IHttpClientFactory _httpClientFactory;
private readonly ILogger _logger;
private readonly object _timerLock = new object();
private Timer _timer; private Timer _timer;
private int _muteVol;
private int _volume;
private DateTime _lastVolumeRefresh;
private bool _volumeRefreshActive;
private int _connectFailureCount;
private bool _disposed;
public Device(DeviceInfo deviceProperties, IHttpClientFactory httpClientFactory, ILogger logger)
{
Properties = deviceProperties;
_httpClientFactory = httpClientFactory;
_logger = logger;
}
public event EventHandler<PlaybackStartEventArgs> PlaybackStart;
public event EventHandler<PlaybackProgressEventArgs> PlaybackProgress;
public event EventHandler<PlaybackStoppedEventArgs> PlaybackStopped;
public event EventHandler<MediaChangedEventArgs> MediaChanged;
public DeviceInfo Properties { get; set; } public DeviceInfo Properties { get; set; }
private int _muteVol;
public bool IsMuted { get; set; } public bool IsMuted { get; set; }
private int _volume;
public int Volume public int Volume
{ {
get get
@@ -67,21 +43,29 @@ namespace Emby.Dlna.PlayTo
public TimeSpan Position { get; set; } = TimeSpan.FromSeconds(0); public TimeSpan Position { get; set; } = TimeSpan.FromSeconds(0);
public TransportState TransportState { get; private set; } public TRANSPORTSTATE TransportState { get; private set; }
public bool IsPlaying => TransportState == TransportState.Playing; public bool IsPlaying => TransportState == TRANSPORTSTATE.PLAYING;
public bool IsPaused => TransportState == TransportState.Paused || TransportState == TransportState.PausedPlayback; public bool IsPaused => TransportState == TRANSPORTSTATE.PAUSED || TransportState == TRANSPORTSTATE.PAUSED_PLAYBACK;
public bool IsStopped => TransportState == TransportState.Stopped; public bool IsStopped => TransportState == TRANSPORTSTATE.STOPPED;
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly IServerConfigurationManager _config;
public Action OnDeviceUnavailable { get; set; } public Action OnDeviceUnavailable { get; set; }
private TransportCommands AvCommands { get; set; } public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config)
{
private TransportCommands RendererCommands { get; set; } Properties = deviceProperties;
_httpClient = httpClient;
public UBaseObject CurrentMediaInfo { get; private set; } _logger = logger;
_config = config;
}
public void Start() public void Start()
{ {
@@ -89,6 +73,8 @@ namespace Emby.Dlna.PlayTo
_timer = new Timer(TimerCallback, null, 1000, Timeout.Infinite); _timer = new Timer(TimerCallback, null, 1000, Timeout.Infinite);
} }
private DateTime _lastVolumeRefresh;
private bool _volumeRefreshActive;
private Task RefreshVolumeIfNeeded() private Task RefreshVolumeIfNeeded()
{ {
if (_volumeRefreshActive if (_volumeRefreshActive
@@ -119,6 +105,7 @@ namespace Emby.Dlna.PlayTo
} }
} }
private readonly object _timerLock = new object();
private void RestartTimer(bool immediate = false) private void RestartTimer(bool immediate = false)
{ {
lock (_timerLock) lock (_timerLock)
@@ -219,7 +206,7 @@ namespace Emby.Dlna.PlayTo
{ {
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetMute"); var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetMute");
if (command == null) if (command == null)
{ {
return false; return false;
@@ -235,7 +222,7 @@ namespace Emby.Dlna.PlayTo
_logger.LogDebug("Setting mute"); _logger.LogDebug("Setting mute");
var value = mute ? 1 : 0; var value = mute ? 1 : 0;
await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(Properties.BaseUrl, service, command.Name, rendererCommands.BuildPost(command, service.ServiceType, value)) await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, rendererCommands.BuildPost(command, service.ServiceType, value))
.ConfigureAwait(false); .ConfigureAwait(false);
IsMuted = mute; IsMuted = mute;
@@ -246,14 +233,11 @@ namespace Emby.Dlna.PlayTo
/// <summary> /// <summary>
/// Sets volume on a scale of 0-100. /// Sets volume on a scale of 0-100.
/// </summary> /// </summary>
/// <param name="value">The volume on a scale of 0-100.</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public async Task SetVolume(int value, CancellationToken cancellationToken) public async Task SetVolume(int value, CancellationToken cancellationToken)
{ {
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume"); var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetVolume");
if (command == null) if (command == null)
{ {
return; return;
@@ -270,7 +254,7 @@ namespace Emby.Dlna.PlayTo
// Remote control will perform better // Remote control will perform better
Volume = value; Volume = value;
await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(Properties.BaseUrl, service, command.Name, rendererCommands.BuildPost(command, service.ServiceType, value)) await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, rendererCommands.BuildPost(command, service.ServiceType, value))
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@@ -278,7 +262,7 @@ namespace Emby.Dlna.PlayTo
{ {
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Seek"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Seek");
if (command == null) if (command == null)
{ {
return; return;
@@ -291,7 +275,7 @@ namespace Emby.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service"); throw new InvalidOperationException("Unable to find service");
} }
await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, string.Format(CultureInfo.InvariantCulture, "{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME")) await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, string.Format("{0:hh}:{0:mm}:{0:ss}", value), "REL_TIME"))
.ConfigureAwait(false); .ConfigureAwait(false);
RestartTimer(true); RestartTimer(true);
@@ -301,11 +285,11 @@ namespace Emby.Dlna.PlayTo
{ {
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
url = url.Replace("&", "&amp;", StringComparison.Ordinal); url = url.Replace("&", "&amp;");
_logger.LogDebug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", Properties.Name, url, header); _logger.LogDebug("{0} - SetAvTransport Uri: {1} DlnaHeaders: {2}", Properties.Name, url, header);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "SetAVTransportURI");
if (command == null) if (command == null)
{ {
return; return;
@@ -313,8 +297,8 @@ namespace Emby.Dlna.PlayTo
var dictionary = new Dictionary<string, string> var dictionary = new Dictionary<string, string>
{ {
{ "CurrentURI", url }, {"CurrentURI", url},
{ "CurrentURIMetaData", CreateDidlMeta(metaData) } {"CurrentURIMetaData", CreateDidlMeta(metaData)}
}; };
var service = GetAvTransportService(); var service = GetAvTransportService();
@@ -325,7 +309,7 @@ namespace Emby.Dlna.PlayTo
} }
var post = avCommands.BuildPost(command, service.ServiceType, url, dictionary); var post = avCommands.BuildPost(command, service.ServiceType, url, dictionary);
await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(Properties.BaseUrl, service, command.Name, post, header: header) await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, post, header: header)
.ConfigureAwait(false); .ConfigureAwait(false);
await Task.Delay(50).ConfigureAwait(false); await Task.Delay(50).ConfigureAwait(false);
@@ -343,14 +327,14 @@ namespace Emby.Dlna.PlayTo
RestartTimer(true); RestartTimer(true);
} }
private static string CreateDidlMeta(string value) private string CreateDidlMeta(string value)
{ {
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
{ {
return string.Empty; return string.Empty;
} }
return SecurityElement.Escape(value); return DescriptionXmlBuilder.Escape(value);
} }
private Task SetPlay(TransportCommands avCommands, CancellationToken cancellationToken) private Task SetPlay(TransportCommands avCommands, CancellationToken cancellationToken)
@@ -367,7 +351,7 @@ namespace Emby.Dlna.PlayTo
throw new InvalidOperationException("Unable to find service"); throw new InvalidOperationException("Unable to find service");
} }
return new SsdpHttpClient(_httpClientFactory).SendCommandAsync( return new SsdpHttpClient(_httpClient).SendCommandAsync(
Properties.BaseUrl, Properties.BaseUrl,
service, service,
command.Name, command.Name,
@@ -378,10 +362,6 @@ namespace Emby.Dlna.PlayTo
public async Task SetPlay(CancellationToken cancellationToken) public async Task SetPlay(CancellationToken cancellationToken)
{ {
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
if (avCommands == null)
{
return;
}
await SetPlay(avCommands, cancellationToken).ConfigureAwait(false); await SetPlay(avCommands, cancellationToken).ConfigureAwait(false);
@@ -392,7 +372,7 @@ namespace Emby.Dlna.PlayTo
{ {
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Stop"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Stop");
if (command == null) if (command == null)
{ {
return; return;
@@ -400,7 +380,7 @@ namespace Emby.Dlna.PlayTo
var service = GetAvTransportService(); var service = GetAvTransportService();
await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, 1)) await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, 1))
.ConfigureAwait(false); .ConfigureAwait(false);
RestartTimer(true); RestartTimer(true);
@@ -410,7 +390,7 @@ namespace Emby.Dlna.PlayTo
{ {
var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false); var avCommands = await GetAVProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = avCommands?.ServiceActions.FirstOrDefault(c => c.Name == "Pause"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "Pause");
if (command == null) if (command == null)
{ {
return; return;
@@ -418,14 +398,16 @@ namespace Emby.Dlna.PlayTo
var service = GetAvTransportService(); var service = GetAvTransportService();
await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, 1)) await new SsdpHttpClient(_httpClient).SendCommandAsync(Properties.BaseUrl, service, command.Name, avCommands.BuildPost(command, service.ServiceType, 1))
.ConfigureAwait(false); .ConfigureAwait(false);
TransportState = TransportState.Paused; TransportState = TRANSPORTSTATE.PAUSED;
RestartTimer(true); RestartTimer(true);
} }
private int _connectFailureCount;
private async void TimerCallback(object sender) private async void TimerCallback(object sender)
{ {
if (_disposed) if (_disposed)
@@ -454,7 +436,7 @@ namespace Emby.Dlna.PlayTo
if (transportState.HasValue) if (transportState.HasValue)
{ {
// If we're not playing anything no need to get additional data // If we're not playing anything no need to get additional data
if (transportState.Value == TransportState.Stopped) if (transportState.Value == TRANSPORTSTATE.STOPPED)
{ {
UpdateMediaInfo(null, transportState.Value); UpdateMediaInfo(null, transportState.Value);
} }
@@ -482,8 +464,8 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
// If we're not playing anything make sure we don't get data more often than necessary to keep the Session alive // If we're not playing anything make sure we don't get data more often than neccessry to keep the Session alive
if (transportState.Value == TransportState.Stopped) if (transportState.Value == TRANSPORTSTATE.STOPPED)
{ {
RestartTimerInactive(); RestartTimerInactive();
} }
@@ -532,7 +514,7 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetVolume"); var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetVolume");
if (command == null) if (command == null)
{ {
return; return;
@@ -545,7 +527,7 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
var result = await new SsdpHttpClient(_httpClientFactory).SendCommandAsync( var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(
Properties.BaseUrl, Properties.BaseUrl,
service, service,
command.Name, command.Name,
@@ -557,7 +539,7 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
var volume = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetVolumeResponse").Select(i => i.Element("CurrentVolume")).FirstOrDefault(i => i != null); var volume = result.Document.Descendants(uPnpNamespaces.RenderingControl + "GetVolumeResponse").Select(i => i.Element("CurrentVolume")).FirstOrDefault(i => i != null);
var volumeValue = volume?.Value; var volumeValue = volume?.Value;
if (string.IsNullOrWhiteSpace(volumeValue)) if (string.IsNullOrWhiteSpace(volumeValue))
@@ -582,7 +564,7 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
var command = rendererCommands?.ServiceActions.FirstOrDefault(c => c.Name == "GetMute"); var command = rendererCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMute");
if (command == null) if (command == null)
{ {
return; return;
@@ -595,7 +577,7 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
var result = await new SsdpHttpClient(_httpClientFactory).SendCommandAsync( var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(
Properties.BaseUrl, Properties.BaseUrl,
service, service,
command.Name, command.Name,
@@ -607,14 +589,14 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
var valueNode = result.Document.Descendants(UPnpNamespaces.RenderingControl + "GetMuteResponse") var valueNode = result.Document.Descendants(uPnpNamespaces.RenderingControl + "GetMuteResponse")
.Select(i => i.Element("CurrentMute")) .Select(i => i.Element("CurrentMute"))
.FirstOrDefault(i => i != null); .FirstOrDefault(i => i != null);
IsMuted = string.Equals(valueNode?.Value, "1", StringComparison.OrdinalIgnoreCase); IsMuted = string.Equals(valueNode?.Value, "1", StringComparison.OrdinalIgnoreCase);
} }
private async Task<TransportState?> GetTransportInfo(TransportCommands avCommands, CancellationToken cancellationToken) private async Task<TRANSPORTSTATE?> GetTransportInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{ {
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetTransportInfo"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetTransportInfo");
if (command == null) if (command == null)
@@ -628,7 +610,7 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
var result = await new SsdpHttpClient(_httpClientFactory).SendCommandAsync( var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(
Properties.BaseUrl, Properties.BaseUrl,
service, service,
command.Name, command.Name,
@@ -641,12 +623,12 @@ namespace Emby.Dlna.PlayTo
} }
var transportState = var transportState =
result.Document.Descendants(UPnpNamespaces.AvTransport + "GetTransportInfoResponse").Select(i => i.Element("CurrentTransportState")).FirstOrDefault(i => i != null); result.Document.Descendants(uPnpNamespaces.AvTransport + "GetTransportInfoResponse").Select(i => i.Element("CurrentTransportState")).FirstOrDefault(i => i != null);
var transportStateValue = transportState?.Value; var transportStateValue = transportState?.Value;
if (transportStateValue != null if (transportStateValue != null
&& Enum.TryParse(transportStateValue, true, out TransportState state)) && Enum.TryParse(transportStateValue, true, out TRANSPORTSTATE state))
{ {
return state; return state;
} }
@@ -654,7 +636,7 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
private async Task<UBaseObject> GetMediaInfo(TransportCommands avCommands, CancellationToken cancellationToken) private async Task<uBaseObject> GetMediaInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{ {
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetMediaInfo");
if (command == null) if (command == null)
@@ -669,12 +651,8 @@ namespace Emby.Dlna.PlayTo
} }
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
if (rendererCommands == null)
{
return null;
}
var result = await new SsdpHttpClient(_httpClientFactory).SendCommandAsync( var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(
Properties.BaseUrl, Properties.BaseUrl,
service, service,
command.Name, command.Name,
@@ -693,7 +671,7 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
var e = track.Element(UPnpNamespaces.Items) ?? track; var e = track.Element(uPnpNamespaces.items) ?? track;
var elementString = (string)e; var elementString = (string)e;
@@ -709,13 +687,13 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
e = track.Element(UPnpNamespaces.Items) ?? track; e = track.Element(uPnpNamespaces.items) ?? track;
elementString = (string)e; elementString = (string)e;
if (!string.IsNullOrWhiteSpace(elementString)) if (!string.IsNullOrWhiteSpace(elementString))
{ {
return new UBaseObject return new uBaseObject
{ {
Url = elementString Url = elementString
}; };
@@ -724,7 +702,7 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
private async Task<(bool, UBaseObject)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken) private async Task<(bool, uBaseObject)> GetPositionInfo(TransportCommands avCommands, CancellationToken cancellationToken)
{ {
var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo"); var command = avCommands.ServiceActions.FirstOrDefault(c => c.Name == "GetPositionInfo");
if (command == null) if (command == null)
@@ -741,12 +719,7 @@ namespace Emby.Dlna.PlayTo
var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false); var rendererCommands = await GetRenderingProtocolAsync(cancellationToken).ConfigureAwait(false);
if (rendererCommands == null) var result = await new SsdpHttpClient(_httpClient).SendCommandAsync(
{
return (false, null);
}
var result = await new SsdpHttpClient(_httpClientFactory).SendCommandAsync(
Properties.BaseUrl, Properties.BaseUrl,
service, service,
command.Name, command.Name,
@@ -758,11 +731,11 @@ namespace Emby.Dlna.PlayTo
return (false, null); return (false, null);
} }
var trackUriElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i != null); var trackUriElem = result.Document.Descendants(uPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackURI")).FirstOrDefault(i => i != null);
var trackUri = trackUriElem?.Value; var trackUri = trackUriElem == null ? null : trackUriElem.Value;
var durationElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i != null); var durationElem = result.Document.Descendants(uPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("TrackDuration")).FirstOrDefault(i => i != null);
var duration = durationElem?.Value; var duration = durationElem == null ? null : durationElem.Value;
if (!string.IsNullOrWhiteSpace(duration) if (!string.IsNullOrWhiteSpace(duration)
&& !string.Equals(duration, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase)) && !string.Equals(duration, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase))
@@ -774,8 +747,8 @@ namespace Emby.Dlna.PlayTo
Duration = null; Duration = null;
} }
var positionElem = result.Document.Descendants(UPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i != null); var positionElem = result.Document.Descendants(uPnpNamespaces.AvTransport + "GetPositionInfoResponse").Select(i => i.Element("RelTime")).FirstOrDefault(i => i != null);
var position = positionElem?.Value; var position = positionElem == null ? null : positionElem.Value;
if (!string.IsNullOrWhiteSpace(position) && !string.Equals(position, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase)) if (!string.IsNullOrWhiteSpace(position) && !string.Equals(position, "NOT_IMPLEMENTED", StringComparison.OrdinalIgnoreCase))
{ {
@@ -786,7 +759,7 @@ namespace Emby.Dlna.PlayTo
if (track == null) if (track == null)
{ {
// If track is null, some vendors do this, use GetMediaInfo instead. // If track is null, some vendors do this, use GetMediaInfo instead
return (true, null); return (true, null);
} }
@@ -814,7 +787,7 @@ namespace Emby.Dlna.PlayTo
return (true, null); return (true, null);
} }
var e = uPnpResponse.Element(UPnpNamespaces.Items); var e = uPnpResponse.Element(uPnpNamespaces.items);
var uTrack = CreateUBaseObject(e, trackUri); var uTrack = CreateUBaseObject(e, trackUri);
@@ -823,7 +796,7 @@ namespace Emby.Dlna.PlayTo
private XElement ParseResponse(string xml) private XElement ParseResponse(string xml)
{ {
// Handle different variations sent back by devices. // Handle different variations sent back by devices
try try
{ {
return XElement.Parse(xml); return XElement.Parse(xml);
@@ -832,7 +805,7 @@ namespace Emby.Dlna.PlayTo
{ {
} }
// first try to add a root node with a dlna namespace. // first try to add a root node with a dlna namesapce
try try
{ {
return XElement.Parse("<data xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + xml + "</data>") return XElement.Parse("<data xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + xml + "</data>")
@@ -846,7 +819,7 @@ namespace Emby.Dlna.PlayTo
// some devices send back invalid xml // some devices send back invalid xml
try try
{ {
return XElement.Parse(xml.Replace("&", "&amp;", StringComparison.Ordinal)); return XElement.Parse(xml.Replace("&", "&amp;"));
} }
catch (XmlException) catch (XmlException)
{ {
@@ -855,27 +828,27 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
private static UBaseObject CreateUBaseObject(XElement container, string trackUri) private static uBaseObject CreateUBaseObject(XElement container, string trackUri)
{ {
if (container == null) if (container == null)
{ {
throw new ArgumentNullException(nameof(container)); throw new ArgumentNullException(nameof(container));
} }
var url = container.GetValue(UPnpNamespaces.Res); var url = container.GetValue(uPnpNamespaces.Res);
if (string.IsNullOrWhiteSpace(url)) if (string.IsNullOrWhiteSpace(url))
{ {
url = trackUri; url = trackUri;
} }
return new UBaseObject return new uBaseObject
{ {
Id = container.GetAttributeValue(UPnpNamespaces.Id), Id = container.GetAttributeValue(uPnpNamespaces.Id),
ParentId = container.GetAttributeValue(UPnpNamespaces.ParentId), ParentId = container.GetAttributeValue(uPnpNamespaces.ParentId),
Title = container.GetValue(UPnpNamespaces.Title), Title = container.GetValue(uPnpNamespaces.title),
IconUrl = container.GetValue(UPnpNamespaces.Artwork), IconUrl = container.GetValue(uPnpNamespaces.Artwork),
SecondText = string.Empty, SecondText = "",
Url = url, Url = url,
ProtocolInfo = GetProtocolInfo(container), ProtocolInfo = GetProtocolInfo(container),
MetaData = container.ToString() MetaData = container.ToString()
@@ -889,11 +862,11 @@ namespace Emby.Dlna.PlayTo
throw new ArgumentNullException(nameof(container)); throw new ArgumentNullException(nameof(container));
} }
var resElement = container.Element(UPnpNamespaces.Res); var resElement = container.Element(uPnpNamespaces.Res);
if (resElement != null) if (resElement != null)
{ {
var info = resElement.Attribute(UPnpNamespaces.ProtocolInfo); var info = resElement.Attribute(uPnpNamespaces.ProtocolInfo);
if (info != null && !string.IsNullOrWhiteSpace(info.Value)) if (info != null && !string.IsNullOrWhiteSpace(info.Value))
{ {
@@ -924,13 +897,9 @@ namespace Emby.Dlna.PlayTo
string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl); string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl);
var httpClient = new SsdpHttpClient(_httpClientFactory); var httpClient = new SsdpHttpClient(_httpClient);
var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false); var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false);
if (document == null)
{
return null;
}
AvCommands = TransportCommands.Create(document); AvCommands = TransportCommands.Create(document);
return AvCommands; return AvCommands;
@@ -956,13 +925,9 @@ namespace Emby.Dlna.PlayTo
string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl); string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl);
var httpClient = new SsdpHttpClient(_httpClientFactory); var httpClient = new SsdpHttpClient(_httpClient);
_logger.LogDebug("Dlna Device.GetRenderingProtocolAsync"); _logger.LogDebug("Dlna Device.GetRenderingProtocolAsync");
var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false); var document = await httpClient.GetDataAsync(url, cancellationToken).ConfigureAwait(false);
if (document == null)
{
return null;
}
RendererCommands = TransportCommands.Create(document); RendererCommands = TransportCommands.Create(document);
return RendererCommands; return RendererCommands;
@@ -976,12 +941,12 @@ namespace Emby.Dlna.PlayTo
return url; return url;
} }
if (!url.Contains('/', StringComparison.Ordinal)) if (!url.Contains("/"))
{ {
url = "/dmr/" + url; url = "/dmr/" + url;
} }
if (!url.StartsWith('/')) if (!url.StartsWith("/"))
{ {
url = "/" + url; url = "/" + url;
} }
@@ -989,25 +954,25 @@ namespace Emby.Dlna.PlayTo
return baseUrl + url; return baseUrl + url;
} }
public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClientFactory httpClientFactory, ILogger logger, CancellationToken cancellationToken) private TransportCommands AvCommands { get; set; }
private TransportCommands RendererCommands { get; set; }
public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, CancellationToken cancellationToken)
{ {
var ssdpHttpClient = new SsdpHttpClient(httpClientFactory); var ssdpHttpClient = new SsdpHttpClient(httpClient);
var document = await ssdpHttpClient.GetDataAsync(url.ToString(), cancellationToken).ConfigureAwait(false); var document = await ssdpHttpClient.GetDataAsync(url.ToString(), cancellationToken).ConfigureAwait(false);
if (document == null)
{
return null;
}
var friendlyNames = new List<string>(); var friendlyNames = new List<string>();
var name = document.Descendants(UPnpNamespaces.Ud.GetName("friendlyName")).FirstOrDefault(); var name = document.Descendants(uPnpNamespaces.ud.GetName("friendlyName")).FirstOrDefault();
if (name != null && !string.IsNullOrWhiteSpace(name.Value)) if (name != null && !string.IsNullOrWhiteSpace(name.Value))
{ {
friendlyNames.Add(name.Value); friendlyNames.Add(name.Value);
} }
var room = document.Descendants(UPnpNamespaces.Ud.GetName("roomName")).FirstOrDefault(); var room = document.Descendants(uPnpNamespaces.ud.GetName("roomName")).FirstOrDefault();
if (room != null && !string.IsNullOrWhiteSpace(room.Value)) if (room != null && !string.IsNullOrWhiteSpace(room.Value))
{ {
friendlyNames.Add(room.Value); friendlyNames.Add(room.Value);
@@ -1016,77 +981,77 @@ namespace Emby.Dlna.PlayTo
var deviceProperties = new DeviceInfo() var deviceProperties = new DeviceInfo()
{ {
Name = string.Join(" ", friendlyNames), Name = string.Join(" ", friendlyNames),
BaseUrl = string.Format(CultureInfo.InvariantCulture, "http://{0}:{1}", url.Host, url.Port) BaseUrl = string.Format("http://{0}:{1}", url.Host, url.Port)
}; };
var model = document.Descendants(UPnpNamespaces.Ud.GetName("modelName")).FirstOrDefault(); var model = document.Descendants(uPnpNamespaces.ud.GetName("modelName")).FirstOrDefault();
if (model != null) if (model != null)
{ {
deviceProperties.ModelName = model.Value; deviceProperties.ModelName = model.Value;
} }
var modelNumber = document.Descendants(UPnpNamespaces.Ud.GetName("modelNumber")).FirstOrDefault(); var modelNumber = document.Descendants(uPnpNamespaces.ud.GetName("modelNumber")).FirstOrDefault();
if (modelNumber != null) if (modelNumber != null)
{ {
deviceProperties.ModelNumber = modelNumber.Value; deviceProperties.ModelNumber = modelNumber.Value;
} }
var uuid = document.Descendants(UPnpNamespaces.Ud.GetName("UDN")).FirstOrDefault(); var uuid = document.Descendants(uPnpNamespaces.ud.GetName("UDN")).FirstOrDefault();
if (uuid != null) if (uuid != null)
{ {
deviceProperties.UUID = uuid.Value; deviceProperties.UUID = uuid.Value;
} }
var manufacturer = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturer")).FirstOrDefault(); var manufacturer = document.Descendants(uPnpNamespaces.ud.GetName("manufacturer")).FirstOrDefault();
if (manufacturer != null) if (manufacturer != null)
{ {
deviceProperties.Manufacturer = manufacturer.Value; deviceProperties.Manufacturer = manufacturer.Value;
} }
var manufacturerUrl = document.Descendants(UPnpNamespaces.Ud.GetName("manufacturerURL")).FirstOrDefault(); var manufacturerUrl = document.Descendants(uPnpNamespaces.ud.GetName("manufacturerURL")).FirstOrDefault();
if (manufacturerUrl != null) if (manufacturerUrl != null)
{ {
deviceProperties.ManufacturerUrl = manufacturerUrl.Value; deviceProperties.ManufacturerUrl = manufacturerUrl.Value;
} }
var presentationUrl = document.Descendants(UPnpNamespaces.Ud.GetName("presentationURL")).FirstOrDefault(); var presentationUrl = document.Descendants(uPnpNamespaces.ud.GetName("presentationURL")).FirstOrDefault();
if (presentationUrl != null) if (presentationUrl != null)
{ {
deviceProperties.PresentationUrl = presentationUrl.Value; deviceProperties.PresentationUrl = presentationUrl.Value;
} }
var modelUrl = document.Descendants(UPnpNamespaces.Ud.GetName("modelURL")).FirstOrDefault(); var modelUrl = document.Descendants(uPnpNamespaces.ud.GetName("modelURL")).FirstOrDefault();
if (modelUrl != null) if (modelUrl != null)
{ {
deviceProperties.ModelUrl = modelUrl.Value; deviceProperties.ModelUrl = modelUrl.Value;
} }
var serialNumber = document.Descendants(UPnpNamespaces.Ud.GetName("serialNumber")).FirstOrDefault(); var serialNumber = document.Descendants(uPnpNamespaces.ud.GetName("serialNumber")).FirstOrDefault();
if (serialNumber != null) if (serialNumber != null)
{ {
deviceProperties.SerialNumber = serialNumber.Value; deviceProperties.SerialNumber = serialNumber.Value;
} }
var modelDescription = document.Descendants(UPnpNamespaces.Ud.GetName("modelDescription")).FirstOrDefault(); var modelDescription = document.Descendants(uPnpNamespaces.ud.GetName("modelDescription")).FirstOrDefault();
if (modelDescription != null) if (modelDescription != null)
{ {
deviceProperties.ModelDescription = modelDescription.Value; deviceProperties.ModelDescription = modelDescription.Value;
} }
var icon = document.Descendants(UPnpNamespaces.Ud.GetName("icon")).FirstOrDefault(); var icon = document.Descendants(uPnpNamespaces.ud.GetName("icon")).FirstOrDefault();
if (icon != null) if (icon != null)
{ {
deviceProperties.Icon = CreateIcon(icon); deviceProperties.Icon = CreateIcon(icon);
} }
foreach (var services in document.Descendants(UPnpNamespaces.Ud.GetName("serviceList"))) foreach (var services in document.Descendants(uPnpNamespaces.ud.GetName("serviceList")))
{ {
if (services == null) if (services == null)
{ {
continue; continue;
} }
var servicesList = services.Descendants(UPnpNamespaces.Ud.GetName("service")); var servicesList = services.Descendants(uPnpNamespaces.ud.GetName("service"));
if (servicesList == null) if (servicesList == null)
{ {
continue; continue;
@@ -1103,9 +1068,10 @@ namespace Emby.Dlna.PlayTo
} }
} }
return new Device(deviceProperties, httpClientFactory, logger); return new Device(deviceProperties, httpClient, logger, config);
} }
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
private static DeviceIcon CreateIcon(XElement element) private static DeviceIcon CreateIcon(XElement element)
{ {
if (element == null) if (element == null)
@@ -1113,11 +1079,11 @@ namespace Emby.Dlna.PlayTo
throw new ArgumentNullException(nameof(element)); throw new ArgumentNullException(nameof(element));
} }
var mimeType = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("mimetype")); var mimeType = element.GetDescendantValue(uPnpNamespaces.ud.GetName("mimetype"));
var width = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("width")); var width = element.GetDescendantValue(uPnpNamespaces.ud.GetName("width"));
var height = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("height")); var height = element.GetDescendantValue(uPnpNamespaces.ud.GetName("height"));
var depth = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("depth")); var depth = element.GetDescendantValue(uPnpNamespaces.ud.GetName("depth"));
var url = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("url")); var url = element.GetDescendantValue(uPnpNamespaces.ud.GetName("url"));
var widthValue = int.Parse(width, NumberStyles.Integer, UsCulture); var widthValue = int.Parse(width, NumberStyles.Integer, UsCulture);
var heightValue = int.Parse(height, NumberStyles.Integer, UsCulture); var heightValue = int.Parse(height, NumberStyles.Integer, UsCulture);
@@ -1134,11 +1100,11 @@ namespace Emby.Dlna.PlayTo
private static DeviceService Create(XElement element) private static DeviceService Create(XElement element)
{ {
var type = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("serviceType")); var type = element.GetDescendantValue(uPnpNamespaces.ud.GetName("serviceType"));
var id = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("serviceId")); var id = element.GetDescendantValue(uPnpNamespaces.ud.GetName("serviceId"));
var scpdUrl = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("SCPDURL")); var scpdUrl = element.GetDescendantValue(uPnpNamespaces.ud.GetName("SCPDURL"));
var controlURL = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("controlURL")); var controlURL = element.GetDescendantValue(uPnpNamespaces.ud.GetName("controlURL"));
var eventSubURL = element.GetDescendantValue(UPnpNamespaces.Ud.GetName("eventSubURL")); var eventSubURL = element.GetDescendantValue(uPnpNamespaces.ud.GetName("eventSubURL"));
return new DeviceService return new DeviceService
{ {
@@ -1150,7 +1116,14 @@ namespace Emby.Dlna.PlayTo
}; };
} }
private void UpdateMediaInfo(UBaseObject mediaInfo, TransportState state) public event EventHandler<PlaybackStartEventArgs> PlaybackStart;
public event EventHandler<PlaybackProgressEventArgs> PlaybackProgress;
public event EventHandler<PlaybackStoppedEventArgs> PlaybackStopped;
public event EventHandler<MediaChangedEventArgs> MediaChanged;
public uBaseObject CurrentMediaInfo { get; private set; }
private void UpdateMediaInfo(uBaseObject mediaInfo, TRANSPORTSTATE state)
{ {
TransportState = state; TransportState = state;
@@ -1159,7 +1132,7 @@ namespace Emby.Dlna.PlayTo
if (previousMediaInfo == null && mediaInfo != null) if (previousMediaInfo == null && mediaInfo != null)
{ {
if (state != TransportState.Stopped) if (state != TRANSPORTSTATE.STOPPED)
{ {
OnPlaybackStart(mediaInfo); OnPlaybackStart(mediaInfo);
} }
@@ -1178,7 +1151,7 @@ namespace Emby.Dlna.PlayTo
} }
} }
private void OnPlaybackStart(UBaseObject mediaInfo) private void OnPlaybackStart(uBaseObject mediaInfo)
{ {
if (string.IsNullOrWhiteSpace(mediaInfo.Url)) if (string.IsNullOrWhiteSpace(mediaInfo.Url))
{ {
@@ -1191,7 +1164,7 @@ namespace Emby.Dlna.PlayTo
}); });
} }
private void OnPlaybackProgress(UBaseObject mediaInfo) private void OnPlaybackProgress(uBaseObject mediaInfo)
{ {
if (string.IsNullOrWhiteSpace(mediaInfo.Url)) if (string.IsNullOrWhiteSpace(mediaInfo.Url))
{ {
@@ -1204,7 +1177,7 @@ namespace Emby.Dlna.PlayTo
}); });
} }
private void OnPlaybackStop(UBaseObject mediaInfo) private void OnPlaybackStop(uBaseObject mediaInfo)
{ {
PlaybackStopped?.Invoke(this, new PlaybackStoppedEventArgs PlaybackStopped?.Invoke(this, new PlaybackStoppedEventArgs
{ {
@@ -1212,7 +1185,7 @@ namespace Emby.Dlna.PlayTo
}); });
} }
private void OnMediaChanged(UBaseObject old, UBaseObject newMedia) private void OnMediaChanged(uBaseObject old, uBaseObject newMedia)
{ {
MediaChanged?.Invoke(this, new MediaChangedEventArgs MediaChanged?.Invoke(this, new MediaChangedEventArgs
{ {
@@ -1221,17 +1194,14 @@ namespace Emby.Dlna.PlayTo
}); });
} }
/// <inheritdoc /> bool _disposed;
public void Dispose() public void Dispose()
{ {
Dispose(true); Dispose(true);
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary>
/// Releases unmanaged and optionally managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (_disposed) if (_disposed)
@@ -1250,10 +1220,9 @@ namespace Emby.Dlna.PlayTo
_disposed = true; _disposed = true;
} }
/// <inheritdoc />
public override string ToString() public override string ToString()
{ {
return string.Format(CultureInfo.InvariantCulture, "{0} - {1}", Properties.Name, Properties.BaseUrl); return string.Format("{0} - {1}", Properties.Name, Properties.BaseUrl);
} }
} }
} }
+2 -3
View File
@@ -8,9 +8,6 @@ namespace Emby.Dlna.PlayTo
{ {
public class DeviceInfo public class DeviceInfo
{ {
private readonly List<DeviceService> _services = new List<DeviceService>();
private string _baseUrl = string.Empty;
public DeviceInfo() public DeviceInfo()
{ {
Name = "Generic Device"; Name = "Generic Device";
@@ -36,6 +33,7 @@ namespace Emby.Dlna.PlayTo
public string PresentationUrl { get; set; } public string PresentationUrl { get; set; }
private string _baseUrl = string.Empty;
public string BaseUrl public string BaseUrl
{ {
get => _baseUrl; get => _baseUrl;
@@ -44,6 +42,7 @@ namespace Emby.Dlna.PlayTo
public DeviceIcon Icon { get; set; } public DeviceIcon Icon { get; set; }
private readonly List<DeviceService> _services = new List<DeviceService>();
public List<DeviceService> Services => _services; public List<DeviceService> Services => _services;
public DeviceIdentification ToDeviceIdentification() public DeviceIdentification ToDeviceIdentification()
-13
View File
@@ -1,13 +0,0 @@
#pragma warning disable CS1591
using System;
namespace Emby.Dlna.PlayTo
{
public class MediaChangedEventArgs : EventArgs
{
public UBaseObject OldMediaInfo { get; set; }
public UBaseObject NewMediaInfo { get; set; }
}
}
+191 -189
View File
@@ -8,7 +8,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Emby.Dlna.Didl; using Emby.Dlna.Didl;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using Jellyfin.Data.Events; using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
@@ -18,6 +18,7 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Session; using MediaBrowser.Model.Session;
using Microsoft.AspNetCore.WebUtilities; using Microsoft.AspNetCore.WebUtilities;
@@ -30,6 +31,7 @@ namespace Emby.Dlna.PlayTo
{ {
private static readonly CultureInfo _usCulture = CultureInfo.ReadOnly(new CultureInfo("en-US")); private static readonly CultureInfo _usCulture = CultureInfo.ReadOnly(new CultureInfo("en-US"));
private Device _device;
private readonly SessionInfo _session; private readonly SessionInfo _session;
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
@@ -40,6 +42,7 @@ namespace Emby.Dlna.PlayTo
private readonly IUserDataManager _userDataManager; private readonly IUserDataManager _userDataManager;
private readonly ILocalizationManager _localization; private readonly ILocalizationManager _localization;
private readonly IMediaSourceManager _mediaSourceManager; private readonly IMediaSourceManager _mediaSourceManager;
private readonly IConfigurationManager _config;
private readonly IMediaEncoder _mediaEncoder; private readonly IMediaEncoder _mediaEncoder;
private readonly IDeviceDiscovery _deviceDiscovery; private readonly IDeviceDiscovery _deviceDiscovery;
@@ -47,7 +50,6 @@ namespace Emby.Dlna.PlayTo
private readonly string _accessToken; private readonly string _accessToken;
private readonly List<PlaylistItem> _playlist = new List<PlaylistItem>(); private readonly List<PlaylistItem> _playlist = new List<PlaylistItem>();
private Device _device;
private int _currentPlaylistIndex; private int _currentPlaylistIndex;
private bool _disposed; private bool _disposed;
@@ -66,6 +68,7 @@ namespace Emby.Dlna.PlayTo
IUserDataManager userDataManager, IUserDataManager userDataManager,
ILocalizationManager localization, ILocalizationManager localization,
IMediaSourceManager mediaSourceManager, IMediaSourceManager mediaSourceManager,
IConfigurationManager config,
IMediaEncoder mediaEncoder) IMediaEncoder mediaEncoder)
{ {
_session = session; _session = session;
@@ -81,6 +84,7 @@ namespace Emby.Dlna.PlayTo
_userDataManager = userDataManager; _userDataManager = userDataManager;
_localization = localization; _localization = localization;
_mediaSourceManager = mediaSourceManager; _mediaSourceManager = mediaSourceManager;
_config = config;
_mediaEncoder = mediaEncoder; _mediaEncoder = mediaEncoder;
} }
@@ -132,7 +136,7 @@ namespace Emby.Dlna.PlayTo
private async void OnDeviceMediaChanged(object sender, MediaChangedEventArgs e) private async void OnDeviceMediaChanged(object sender, MediaChangedEventArgs e)
{ {
if (_disposed || string.IsNullOrEmpty(e.OldMediaInfo.Url)) if (_disposed)
{ {
return; return;
} }
@@ -322,7 +326,7 @@ namespace Emby.Dlna.PlayTo
public Task SendPlayCommand(PlayRequest command, CancellationToken cancellationToken) public Task SendPlayCommand(PlayRequest command, CancellationToken cancellationToken)
{ {
_logger.LogDebug("{0} - Received PlayRequest: {1}", _session.DeviceName, command.PlayCommand); _logger.LogDebug("{0} - Received PlayRequest: {1}", this._session.DeviceName, command.PlayCommand);
var user = command.ControllingUserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(command.ControllingUserId); var user = command.ControllingUserId.Equals(Guid.Empty) ? null : _userManager.GetUserById(command.ControllingUserId);
@@ -333,26 +337,25 @@ namespace Emby.Dlna.PlayTo
} }
var startIndex = command.StartIndex ?? 0; var startIndex = command.StartIndex ?? 0;
int len = items.Count - startIndex;
if (startIndex > 0) if (startIndex > 0)
{ {
items = items.GetRange(startIndex, len); items = items.Skip(startIndex).ToList();
} }
var playlist = new PlaylistItem[len]; var playlist = new List<PlaylistItem>();
var isFirst = true;
// Not nullable enabled - so this is required. foreach (var item in items)
playlist[0] = CreatePlaylistItem(
items[0],
user,
command.StartPositionTicks ?? 0,
command.MediaSourceId ?? string.Empty,
command.AudioStreamIndex,
command.SubtitleStreamIndex);
for (int i = 1; i < len; i++)
{ {
playlist[i] = CreatePlaylistItem(items[i], user, 0, string.Empty, null, null); if (isFirst && command.StartPositionTicks.HasValue)
{
playlist.Add(CreatePlaylistItem(item, user, command.StartPositionTicks.Value, command.MediaSourceId, command.AudioStreamIndex, command.SubtitleStreamIndex));
isFirst = false;
}
else
{
playlist.Add(CreatePlaylistItem(item, user, 0, null, null, null));
}
} }
_logger.LogDebug("{0} - Playlist created", _session.DeviceName); _logger.LogDebug("{0} - Playlist created", _session.DeviceName);
@@ -369,13 +372,8 @@ namespace Emby.Dlna.PlayTo
if (!command.ControllingUserId.Equals(Guid.Empty)) if (!command.ControllingUserId.Equals(Guid.Empty))
{ {
_sessionManager.LogSessionActivity( _sessionManager.LogSessionActivity(_session.Client, _session.ApplicationVersion, _session.DeviceId,
_session.Client, _session.DeviceName, _session.RemoteEndPoint, user);
_session.ApplicationVersion,
_session.DeviceId,
_session.DeviceName,
_session.RemoteEndPoint,
user);
} }
return PlayItems(playlist, cancellationToken); return PlayItems(playlist, cancellationToken);
@@ -465,8 +463,8 @@ namespace Emby.Dlna.PlayTo
_dlnaManager.GetDefaultProfile(); _dlnaManager.GetDefaultProfile();
var mediaSources = item is IHasMediaSources var mediaSources = item is IHasMediaSources
? _mediaSourceManager.GetStaticMediaSources(item, true, user).ToArray() ? _mediaSourceManager.GetStaticMediaSources(item, true, user)
: Array.Empty<MediaSourceInfo>(); : new List<MediaSourceInfo>();
var playlistItem = GetPlaylistItem(item, mediaSources, profile, _session.DeviceId, mediaSourceId, audioStreamIndex, subtitleStreamIndex); var playlistItem = GetPlaylistItem(item, mediaSources, profile, _session.DeviceId, mediaSourceId, audioStreamIndex, subtitleStreamIndex);
playlistItem.StreamInfo.StartPositionTicks = startPostionTicks; playlistItem.StreamInfo.StartPositionTicks = startPostionTicks;
@@ -500,44 +498,42 @@ namespace Emby.Dlna.PlayTo
if (streamInfo.MediaType == DlnaProfileType.Audio) if (streamInfo.MediaType == DlnaProfileType.Audio)
{ {
return new ContentFeatureBuilder(profile) return new ContentFeatureBuilder(profile)
.BuildAudioHeader( .BuildAudioHeader(streamInfo.Container,
streamInfo.Container, streamInfo.TargetAudioCodec.FirstOrDefault(),
streamInfo.TargetAudioCodec.FirstOrDefault(), streamInfo.TargetAudioBitrate,
streamInfo.TargetAudioBitrate, streamInfo.TargetAudioSampleRate,
streamInfo.TargetAudioSampleRate, streamInfo.TargetAudioChannels,
streamInfo.TargetAudioChannels, streamInfo.TargetAudioBitDepth,
streamInfo.TargetAudioBitDepth, streamInfo.IsDirectStream,
streamInfo.IsDirectStream, streamInfo.RunTimeTicks ?? 0,
streamInfo.RunTimeTicks ?? 0, streamInfo.TranscodeSeekInfo);
streamInfo.TranscodeSeekInfo);
} }
if (streamInfo.MediaType == DlnaProfileType.Video) if (streamInfo.MediaType == DlnaProfileType.Video)
{ {
var list = new ContentFeatureBuilder(profile) var list = new ContentFeatureBuilder(profile)
.BuildVideoHeader( .BuildVideoHeader(streamInfo.Container,
streamInfo.Container, streamInfo.TargetVideoCodec.FirstOrDefault(),
streamInfo.TargetVideoCodec.FirstOrDefault(), streamInfo.TargetAudioCodec.FirstOrDefault(),
streamInfo.TargetAudioCodec.FirstOrDefault(), streamInfo.TargetWidth,
streamInfo.TargetWidth, streamInfo.TargetHeight,
streamInfo.TargetHeight, streamInfo.TargetVideoBitDepth,
streamInfo.TargetVideoBitDepth, streamInfo.TargetVideoBitrate,
streamInfo.TargetVideoBitrate, streamInfo.TargetTimestamp,
streamInfo.TargetTimestamp, streamInfo.IsDirectStream,
streamInfo.IsDirectStream, streamInfo.RunTimeTicks ?? 0,
streamInfo.RunTimeTicks ?? 0, streamInfo.TargetVideoProfile,
streamInfo.TargetVideoProfile, streamInfo.TargetVideoLevel,
streamInfo.TargetVideoLevel, streamInfo.TargetFramerate ?? 0,
streamInfo.TargetFramerate ?? 0, streamInfo.TargetPacketLength,
streamInfo.TargetPacketLength, streamInfo.TranscodeSeekInfo,
streamInfo.TranscodeSeekInfo, streamInfo.IsTargetAnamorphic,
streamInfo.IsTargetAnamorphic, streamInfo.IsTargetInterlaced,
streamInfo.IsTargetInterlaced, streamInfo.TargetRefFrames,
streamInfo.TargetRefFrames, streamInfo.TargetVideoStreamCount,
streamInfo.TargetVideoStreamCount, streamInfo.TargetAudioStreamCount,
streamInfo.TargetAudioStreamCount, streamInfo.TargetVideoCodecTag,
streamInfo.TargetVideoCodecTag, streamInfo.IsTargetAVC);
streamInfo.IsTargetAVC);
return list.Count == 0 ? null : list[0]; return list.Count == 0 ? null : list[0];
} }
@@ -545,7 +541,7 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
private PlaylistItem GetPlaylistItem(BaseItem item, MediaSourceInfo[] mediaSources, DeviceProfile profile, string deviceId, string mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex) private PlaylistItem GetPlaylistItem(BaseItem item, List<MediaSourceInfo> mediaSources, DeviceProfile profile, string deviceId, string mediaSourceId, int? audioStreamIndex, int? subtitleStreamIndex)
{ {
if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
{ {
@@ -554,7 +550,7 @@ namespace Emby.Dlna.PlayTo
StreamInfo = new StreamBuilder(_mediaEncoder, _logger).BuildVideoItem(new VideoOptions StreamInfo = new StreamBuilder(_mediaEncoder, _logger).BuildVideoItem(new VideoOptions
{ {
ItemId = item.Id, ItemId = item.Id,
MediaSources = mediaSources, MediaSources = mediaSources.ToArray(),
Profile = profile, Profile = profile,
DeviceId = deviceId, DeviceId = deviceId,
MaxBitrate = profile.MaxStreamingBitrate, MaxBitrate = profile.MaxStreamingBitrate,
@@ -574,7 +570,7 @@ namespace Emby.Dlna.PlayTo
StreamInfo = new StreamBuilder(_mediaEncoder, _logger).BuildAudioItem(new AudioOptions StreamInfo = new StreamBuilder(_mediaEncoder, _logger).BuildAudioItem(new AudioOptions
{ {
ItemId = item.Id, ItemId = item.Id,
MediaSources = mediaSources, MediaSources = mediaSources.ToArray(),
Profile = profile, Profile = profile,
DeviceId = deviceId, DeviceId = deviceId,
MaxBitrate = profile.MaxStreamingBitrate, MaxBitrate = profile.MaxStreamingBitrate,
@@ -587,7 +583,7 @@ namespace Emby.Dlna.PlayTo
if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase)) if (string.Equals(item.MediaType, MediaType.Photo, StringComparison.OrdinalIgnoreCase))
{ {
return PlaylistItemFactory.Create((Photo)item, profile); return new PlaylistItemFactory().Create((Photo)item, profile);
} }
throw new ArgumentException("Unrecognized item type."); throw new ArgumentException("Unrecognized item type.");
@@ -637,10 +633,6 @@ namespace Emby.Dlna.PlayTo
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
/// <summary>
/// Releases unmanaged and optionally managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (_disposed) if (_disposed)
@@ -666,57 +658,69 @@ namespace Emby.Dlna.PlayTo
private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken) private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken)
{ {
switch (command.Name) if (Enum.TryParse(command.Name, true, out GeneralCommandType commandType))
{ {
case GeneralCommandType.VolumeDown: switch (commandType)
return _device.VolumeDown(cancellationToken); {
case GeneralCommandType.VolumeUp: case GeneralCommandType.VolumeDown:
return _device.VolumeUp(cancellationToken); return _device.VolumeDown(cancellationToken);
case GeneralCommandType.Mute: case GeneralCommandType.VolumeUp:
return _device.Mute(cancellationToken); return _device.VolumeUp(cancellationToken);
case GeneralCommandType.Unmute: case GeneralCommandType.Mute:
return _device.Unmute(cancellationToken); return _device.Mute(cancellationToken);
case GeneralCommandType.ToggleMute: case GeneralCommandType.Unmute:
return _device.ToggleMute(cancellationToken); return _device.Unmute(cancellationToken);
case GeneralCommandType.SetAudioStreamIndex: case GeneralCommandType.ToggleMute:
if (command.Arguments.TryGetValue("Index", out string index)) return _device.ToggleMute(cancellationToken);
{ case GeneralCommandType.SetAudioStreamIndex:
if (int.TryParse(index, NumberStyles.Integer, _usCulture, out var val))
{ {
return SetAudioStreamIndex(val); if (command.Arguments.TryGetValue("Index", out string arg))
{
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var val))
{
return SetAudioStreamIndex(val);
}
throw new ArgumentException("Unsupported SetAudioStreamIndex value supplied.");
}
throw new ArgumentException("SetAudioStreamIndex argument cannot be null");
}
case GeneralCommandType.SetSubtitleStreamIndex:
{
if (command.Arguments.TryGetValue("Index", out string arg))
{
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var val))
{
return SetSubtitleStreamIndex(val);
}
throw new ArgumentException("Unsupported SetSubtitleStreamIndex value supplied.");
}
throw new ArgumentException("SetSubtitleStreamIndex argument cannot be null");
}
case GeneralCommandType.SetVolume:
{
if (command.Arguments.TryGetValue("Volume", out string arg))
{
if (int.TryParse(arg, NumberStyles.Integer, _usCulture, out var volume))
{
return _device.SetVolume(volume, cancellationToken);
}
throw new ArgumentException("Unsupported volume value supplied.");
}
throw new ArgumentException("Volume argument cannot be null");
} }
throw new ArgumentException("Unsupported SetAudioStreamIndex value supplied."); default:
} return Task.CompletedTask;
}
throw new ArgumentException("SetAudioStreamIndex argument cannot be null");
case GeneralCommandType.SetSubtitleStreamIndex:
if (command.Arguments.TryGetValue("Index", out index))
{
if (int.TryParse(index, NumberStyles.Integer, _usCulture, out var val))
{
return SetSubtitleStreamIndex(val);
}
throw new ArgumentException("Unsupported SetSubtitleStreamIndex value supplied.");
}
throw new ArgumentException("SetSubtitleStreamIndex argument cannot be null");
case GeneralCommandType.SetVolume:
if (command.Arguments.TryGetValue("Volume", out string vol))
{
if (int.TryParse(vol, NumberStyles.Integer, _usCulture, out var volume))
{
return _device.SetVolume(volume, cancellationToken);
}
throw new ArgumentException("Unsupported volume value supplied.");
}
throw new ArgumentException("Volume argument cannot be null");
default:
return Task.CompletedTask;
} }
return Task.CompletedTask;
} }
private async Task SetAudioStreamIndex(int? newIndex) private async Task SetAudioStreamIndex(int? newIndex)
@@ -771,80 +775,20 @@ namespace Emby.Dlna.PlayTo
private async Task SeekAfterTransportChange(long positionTicks, CancellationToken cancellationToken) private async Task SeekAfterTransportChange(long positionTicks, CancellationToken cancellationToken)
{ {
const int MaxWait = 15000000; const int maxWait = 15000000;
const int Interval = 500; const int interval = 500;
var currentWait = 0; var currentWait = 0;
while (_device.TransportState != TransportState.Playing && currentWait < MaxWait) while (_device.TransportState != TRANSPORTSTATE.PLAYING && currentWait < maxWait)
{ {
await Task.Delay(Interval).ConfigureAwait(false); await Task.Delay(interval).ConfigureAwait(false);
currentWait += Interval; currentWait += interval;
} }
await _device.Seek(TimeSpan.FromTicks(positionTicks), cancellationToken).ConfigureAwait(false); await _device.Seek(TimeSpan.FromTicks(positionTicks), cancellationToken).ConfigureAwait(false);
} }
private static int? GetIntValue(IReadOnlyDictionary<string, string> values, string name)
{
var value = values.GetValueOrDefault(name);
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return null;
}
private static long GetLongValue(IReadOnlyDictionary<string, string> values, string name)
{
var value = values.GetValueOrDefault(name);
if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return 0;
}
/// <inheritdoc />
public Task SendMessage<T>(SessionMessageType name, Guid messageId, T data, CancellationToken cancellationToken)
{
if (_disposed)
{
throw new ObjectDisposedException(GetType().Name);
}
if (_device == null)
{
return Task.CompletedTask;
}
if (name == SessionMessageType.Play)
{
return SendPlayCommand(data as PlayRequest, cancellationToken);
}
if (name == SessionMessageType.Playstate)
{
return SendPlaystateCommand(data as PlaystateRequest, cancellationToken);
}
if (name == SessionMessageType.GeneralCommand)
{
return SendGeneralCommand(data as GeneralCommand, cancellationToken);
}
// Not supported or needed right now
return Task.CompletedTask;
}
private class StreamParams private class StreamParams
{ {
private MediaSourceInfo mediaSource;
private IMediaSourceManager _mediaSourceManager;
public Guid ItemId { get; set; } public Guid ItemId { get; set; }
public bool IsDirectStream { get; set; } public bool IsDirectStream { get; set; }
@@ -865,11 +809,15 @@ namespace Emby.Dlna.PlayTo
public BaseItem Item { get; set; } public BaseItem Item { get; set; }
private MediaSourceInfo MediaSource;
private IMediaSourceManager _mediaSourceManager;
public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken) public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken)
{ {
if (mediaSource != null) if (MediaSource != null)
{ {
return mediaSource; return MediaSource;
} }
var hasMediaSources = Item as IHasMediaSources; var hasMediaSources = Item as IHasMediaSources;
@@ -879,12 +827,9 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
if (_mediaSourceManager != null) MediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false);
{
mediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false);
}
return mediaSource; return MediaSource;
} }
private static Guid GetItemId(string url) private static Guid GetItemId(string url)
@@ -896,16 +841,16 @@ namespace Emby.Dlna.PlayTo
var parts = url.Split('/'); var parts = url.Split('/');
for (var i = 0; i < parts.Length - 1; i++) for (var i = 0; i < parts.Length; i++)
{ {
var part = parts[i]; var part = parts[i];
if (string.Equals(part, "audio", StringComparison.OrdinalIgnoreCase) || if (string.Equals(part, "audio", StringComparison.OrdinalIgnoreCase) ||
string.Equals(part, "videos", StringComparison.OrdinalIgnoreCase)) string.Equals(part, "videos", StringComparison.OrdinalIgnoreCase))
{ {
if (Guid.TryParse(parts[i + 1], out var result)) if (parts.Length > i + 1)
{ {
return result; return Guid.Parse(parts[i + 1]);
} }
} }
} }
@@ -944,6 +889,7 @@ namespace Emby.Dlna.PlayTo
request.MediaSourceId = values.GetValueOrDefault("MediaSourceId"); request.MediaSourceId = values.GetValueOrDefault("MediaSourceId");
request.LiveStreamId = values.GetValueOrDefault("LiveStreamId"); request.LiveStreamId = values.GetValueOrDefault("LiveStreamId");
request.IsDirectStream = string.Equals("true", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase); request.IsDirectStream = string.Equals("true", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
request.AudioStreamIndex = GetIntValue(values, "AudioStreamIndex"); request.AudioStreamIndex = GetIntValue(values, "AudioStreamIndex");
request.SubtitleStreamIndex = GetIntValue(values, "SubtitleStreamIndex"); request.SubtitleStreamIndex = GetIntValue(values, "SubtitleStreamIndex");
request.StartPositionTicks = GetLongValue(values, "StartPositionTicks"); request.StartPositionTicks = GetLongValue(values, "StartPositionTicks");
@@ -955,5 +901,61 @@ namespace Emby.Dlna.PlayTo
return request; return request;
} }
} }
private static int? GetIntValue(IReadOnlyDictionary<string, string> values, string name)
{
var value = values.GetValueOrDefault(name);
if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return null;
}
private static long GetLongValue(IReadOnlyDictionary<string, string> values, string name)
{
var value = values.GetValueOrDefault(name);
if (long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
{
return result;
}
return 0;
}
/// <inheritdoc />
public Task SendMessage<T>(string name, Guid messageId, T data, CancellationToken cancellationToken)
{
if (_disposed)
{
throw new ObjectDisposedException(GetType().Name);
}
if (_device == null)
{
return Task.CompletedTask;
}
if (string.Equals(name, "Play", StringComparison.OrdinalIgnoreCase))
{
return SendPlayCommand(data as PlayRequest, cancellationToken);
}
if (string.Equals(name, "PlayState", StringComparison.OrdinalIgnoreCase))
{
return SendPlaystateCommand(data as PlaystateRequest, cancellationToken);
}
if (string.Equals(name, "GeneralCommand", StringComparison.OrdinalIgnoreCase))
{
return SendGeneralCommand(data as GeneralCommand, cancellationToken);
}
// Not supported or needed right now
return Task.CompletedTask;
}
} }
} }
+64 -64
View File
@@ -3,11 +3,11 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Data.Events;
using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Dlna;
@@ -16,6 +16,7 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Session; using MediaBrowser.Model.Session;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@@ -32,7 +33,7 @@ namespace Emby.Dlna.PlayTo
private readonly IDlnaManager _dlnaManager; private readonly IDlnaManager _dlnaManager;
private readonly IServerApplicationHost _appHost; private readonly IServerApplicationHost _appHost;
private readonly IImageProcessor _imageProcessor; private readonly IImageProcessor _imageProcessor;
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClient _httpClient;
private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
private readonly IUserDataManager _userDataManager; private readonly IUserDataManager _userDataManager;
private readonly ILocalizationManager _localization; private readonly ILocalizationManager _localization;
@@ -45,7 +46,7 @@ namespace Emby.Dlna.PlayTo
private SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1); private SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource(); private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource();
public PlayToManager(ILogger logger, ISessionManager sessionManager, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, IDeviceDiscovery deviceDiscovery, IHttpClientFactory httpClientFactory, IServerConfigurationManager config, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder) public PlayToManager(ILogger logger, ISessionManager sessionManager, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, IServerConfigurationManager config, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder)
{ {
_logger = logger; _logger = logger;
_sessionManager = sessionManager; _sessionManager = sessionManager;
@@ -55,7 +56,7 @@ namespace Emby.Dlna.PlayTo
_appHost = appHost; _appHost = appHost;
_imageProcessor = imageProcessor; _imageProcessor = imageProcessor;
_deviceDiscovery = deviceDiscovery; _deviceDiscovery = deviceDiscovery;
_httpClientFactory = httpClientFactory; _httpClient = httpClient;
_config = config; _config = config;
_userDataManager = userDataManager; _userDataManager = userDataManager;
_localization = localization; _localization = localization;
@@ -87,10 +88,13 @@ namespace Emby.Dlna.PlayTo
nt = string.Empty; nt = string.Empty;
} }
string location = info.Location.ToString();
// It has to report that it's a media renderer // It has to report that it's a media renderer
if (!usn.Contains("MediaRenderer:", StringComparison.OrdinalIgnoreCase) if (usn.IndexOf("MediaRenderer:", StringComparison.OrdinalIgnoreCase) == -1 &&
&& !nt.Contains("MediaRenderer:", StringComparison.OrdinalIgnoreCase)) nt.IndexOf("MediaRenderer:", StringComparison.OrdinalIgnoreCase) == -1)
{ {
// _logger.LogDebug("Upnp device {0} does not contain a MediaRenderer device (0).", location);
return; return;
} }
@@ -110,7 +114,7 @@ namespace Emby.Dlna.PlayTo
return; return;
} }
await AddDevice(info, cancellationToken).ConfigureAwait(false); await AddDevice(info, location, cancellationToken).ConfigureAwait(false);
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
@@ -125,50 +129,43 @@ namespace Emby.Dlna.PlayTo
} }
} }
internal static string GetUuid(string usn) private string GetUuid(string usn)
{ {
const string UuidStr = "uuid:"; var found = false;
const string UuidColonStr = "::"; var index = usn.IndexOf("uuid:", StringComparison.OrdinalIgnoreCase);
var index = usn.IndexOf(UuidStr, StringComparison.OrdinalIgnoreCase);
if (index == -1)
{
return usn.GetMD5().ToString("N", CultureInfo.InvariantCulture);
}
ReadOnlySpan<char> tmp = usn.AsSpan()[(index + UuidStr.Length)..];
index = tmp.IndexOf(UuidColonStr, StringComparison.OrdinalIgnoreCase);
if (index != -1) if (index != -1)
{ {
tmp = tmp[..index]; usn = usn.Substring(index);
found = true;
} }
index = tmp.IndexOf('{'); index = usn.IndexOf("::", StringComparison.OrdinalIgnoreCase);
if (index != -1) if (index != -1)
{ {
int endIndex = tmp.IndexOf('}'); usn = usn.Substring(0, index);
if (endIndex != -1)
{
tmp = tmp[(index + 1)..endIndex];
}
} }
return tmp.ToString(); if (found)
{
return usn;
}
return usn.GetMD5().ToString("N", CultureInfo.InvariantCulture);
} }
private async Task AddDevice(UpnpDeviceInfo info, CancellationToken cancellationToken) private async Task AddDevice(UpnpDeviceInfo info, string location, CancellationToken cancellationToken)
{ {
var uri = info.Location; var uri = info.Location;
_logger.LogDebug("Attempting to create PlayToController from location {0}", uri); _logger.LogDebug("Attempting to create PlayToController from location {0}", location);
_logger.LogDebug("Logging session activity from location {0}", location);
if (info.Headers.TryGetValue("USN", out string uuid)) if (info.Headers.TryGetValue("USN", out string uuid))
{ {
uuid = GetUuid(uuid); uuid = GetUuid(uuid);
} }
else else
{ {
uuid = uri.ToString().GetMD5().ToString("N", CultureInfo.InvariantCulture); uuid = location.GetMD5().ToString("N", CultureInfo.InvariantCulture);
} }
var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersionString, uuid, null, uri.OriginalString, null); var sessionInfo = _sessionManager.LogSessionActivity("DLNA", _appHost.ApplicationVersionString, uuid, null, uri.OriginalString, null);
@@ -177,34 +174,38 @@ namespace Emby.Dlna.PlayTo
if (controller == null) if (controller == null)
{ {
var device = await Device.CreateuPnpDeviceAsync(uri, _httpClientFactory, _logger, cancellationToken).ConfigureAwait(false); var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, cancellationToken).ConfigureAwait(false);
if (device == null)
{
_logger.LogError("Ignoring device as xml response is invalid.");
return;
}
string deviceName = device.Properties.Name; string deviceName = device.Properties.Name;
_sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName); _sessionManager.UpdateDeviceName(sessionInfo.Id, deviceName);
string serverAddress = _appHost.GetSmartApiUrl(info.LocalIpAddress); string serverAddress;
if (info.LocalIpAddress == null || info.LocalIpAddress.Equals(IPAddress.Any) || info.LocalIpAddress.Equals(IPAddress.IPv6Any))
{
serverAddress = await _appHost.GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
}
else
{
serverAddress = _appHost.GetLocalApiUrl(info.LocalIpAddress);
}
controller = new PlayToController( controller = new PlayToController(
sessionInfo, sessionInfo,
_sessionManager, _sessionManager,
_libraryManager, _libraryManager,
_logger, _logger,
_dlnaManager, _dlnaManager,
_userManager, _userManager,
_imageProcessor, _imageProcessor,
serverAddress, serverAddress,
null, null,
_deviceDiscovery, _deviceDiscovery,
_userDataManager, _userDataManager,
_localization, _localization,
_mediaSourceManager, _mediaSourceManager,
_mediaEncoder); _config,
_mediaEncoder);
sessionInfo.AddController(controller); sessionInfo.AddController(controller);
@@ -217,17 +218,17 @@ namespace Emby.Dlna.PlayTo
{ {
PlayableMediaTypes = profile.GetSupportedMediaTypes(), PlayableMediaTypes = profile.GetSupportedMediaTypes(),
SupportedCommands = new[] SupportedCommands = new string[]
{ {
GeneralCommandType.VolumeDown, GeneralCommandType.VolumeDown.ToString(),
GeneralCommandType.VolumeUp, GeneralCommandType.VolumeUp.ToString(),
GeneralCommandType.Mute, GeneralCommandType.Mute.ToString(),
GeneralCommandType.Unmute, GeneralCommandType.Unmute.ToString(),
GeneralCommandType.ToggleMute, GeneralCommandType.ToggleMute.ToString(),
GeneralCommandType.SetVolume, GeneralCommandType.SetVolume.ToString(),
GeneralCommandType.SetAudioStreamIndex, GeneralCommandType.SetAudioStreamIndex.ToString(),
GeneralCommandType.SetSubtitleStreamIndex, GeneralCommandType.SetSubtitleStreamIndex.ToString(),
GeneralCommandType.PlayMediaSource GeneralCommandType.PlayMediaSource.ToString()
}, },
SupportsMediaControl = true SupportsMediaControl = true
@@ -246,9 +247,8 @@ namespace Emby.Dlna.PlayTo
{ {
_disposeCancellationTokenSource.Cancel(); _disposeCancellationTokenSource.Cancel();
} }
catch (Exception ex) catch
{ {
_logger.LogDebug(ex, "Error while disposing PlayToManager");
} }
_sessionLock.Dispose(); _sessionLock.Dispose();
@@ -6,6 +6,6 @@ namespace Emby.Dlna.PlayTo
{ {
public class PlaybackProgressEventArgs : EventArgs public class PlaybackProgressEventArgs : EventArgs
{ {
public UBaseObject MediaInfo { get; set; } public uBaseObject MediaInfo { get; set; }
} }
} }
+1 -1
View File
@@ -6,6 +6,6 @@ namespace Emby.Dlna.PlayTo
{ {
public class PlaybackStartEventArgs : EventArgs public class PlaybackStartEventArgs : EventArgs
{ {
public UBaseObject MediaInfo { get; set; } public uBaseObject MediaInfo { get; set; }
} }
} }
+8 -1
View File
@@ -6,6 +6,13 @@ namespace Emby.Dlna.PlayTo
{ {
public class PlaybackStoppedEventArgs : EventArgs public class PlaybackStoppedEventArgs : EventArgs
{ {
public UBaseObject MediaInfo { get; set; } public uBaseObject MediaInfo { get; set; }
}
public class MediaChangedEventArgs : EventArgs
{
public uBaseObject OldMediaInfo { get; set; }
public uBaseObject NewMediaInfo { get; set; }
} }
} }
+2 -2
View File
@@ -8,9 +8,9 @@ using MediaBrowser.Model.Session;
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
public static class PlaylistItemFactory public class PlaylistItemFactory
{ {
public static PlaylistItem Create(Photo item, DeviceProfile profile) public PlaylistItem Create(Photo item, DeviceProfile profile)
{ {
var playlistItem = new PlaylistItem var playlistItem = new PlaylistItem
{ {
+68 -48
View File
@@ -4,7 +4,6 @@ using System;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Net.Mime;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -21,11 +20,11 @@ namespace Emby.Dlna.PlayTo
private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly CultureInfo _usCulture = new CultureInfo("en-US");
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClient _httpClient;
public SsdpHttpClient(IHttpClientFactory httpClientFactory) public SsdpHttpClient(IHttpClient httpClient)
{ {
_httpClientFactory = httpClientFactory; _httpClient = httpClient;
} }
public async Task<XDocument> SendCommandAsync( public async Task<XDocument> SendCommandAsync(
@@ -37,18 +36,20 @@ namespace Emby.Dlna.PlayTo
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var url = NormalizeServiceUrl(baseUrl, service.ControlUrl); var url = NormalizeServiceUrl(baseUrl, service.ControlUrl);
using var response = await PostSoapDataAsync( using (var response = await PostSoapDataAsync(
url, url,
$"\"{service.ServiceType}#{command}\"", $"\"{service.ServiceType}#{command}\"",
postData, postData,
header, header,
cancellationToken) cancellationToken)
.ConfigureAwait(false); .ConfigureAwait(false))
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); using (var stream = response.Content)
return await XDocument.LoadAsync( using (var reader = new StreamReader(stream, Encoding.UTF8))
stream, {
LoadOptions.PreserveWhitespace, return XDocument.Parse(
cancellationToken).ConfigureAwait(false); await reader.ReadToEndAsync().ConfigureAwait(false),
LoadOptions.PreserveWhitespace);
}
} }
private static string NormalizeServiceUrl(string baseUrl, string serviceUrl) private static string NormalizeServiceUrl(string baseUrl, string serviceUrl)
@@ -59,7 +60,7 @@ namespace Emby.Dlna.PlayTo
return serviceUrl; return serviceUrl;
} }
if (!serviceUrl.StartsWith('/')) if (!serviceUrl.StartsWith("/", StringComparison.Ordinal))
{ {
serviceUrl = "/" + serviceUrl; serviceUrl = "/" + serviceUrl;
} }
@@ -75,39 +76,49 @@ namespace Emby.Dlna.PlayTo
int eventport, int eventport,
int timeOut = 3600) int timeOut = 3600)
{ {
using var options = new HttpRequestMessage(new HttpMethod("SUBSCRIBE"), url); var options = new HttpRequestOptions
options.Headers.UserAgent.ParseAdd(USERAGENT); {
options.Headers.TryAddWithoutValidation("HOST", ip + ":" + port.ToString(_usCulture)); Url = url,
options.Headers.TryAddWithoutValidation("CALLBACK", "<" + localIp + ":" + eventport.ToString(_usCulture) + ">"); UserAgent = USERAGENT,
options.Headers.TryAddWithoutValidation("NT", "upnp:event"); LogErrorResponseBody = true,
options.Headers.TryAddWithoutValidation("TIMEOUT", "Second-" + timeOut.ToString(_usCulture)); BufferContent = false,
};
using var response = await _httpClientFactory.CreateClient(NamedClient.Default) options.RequestHeaders["HOST"] = ip + ":" + port.ToString(_usCulture);
.SendAsync(options, HttpCompletionOption.ResponseHeadersRead) options.RequestHeaders["CALLBACK"] = "<" + localIp + ":" + eventport.ToString(_usCulture) + ">";
.ConfigureAwait(false); options.RequestHeaders["NT"] = "upnp:event";
options.RequestHeaders["TIMEOUT"] = "Second-" + timeOut.ToString(_usCulture);
using (await _httpClient.SendAsync(options, new HttpMethod("SUBSCRIBE")).ConfigureAwait(false))
{
}
} }
public async Task<XDocument> GetDataAsync(string url, CancellationToken cancellationToken) public async Task<XDocument> GetDataAsync(string url, CancellationToken cancellationToken)
{ {
using var options = new HttpRequestMessage(HttpMethod.Get, url); var options = new HttpRequestOptions
options.Headers.UserAgent.ParseAdd(USERAGENT);
options.Headers.TryAddWithoutValidation("FriendlyName.DLNA.ORG", FriendlyName);
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
try
{ {
return await XDocument.LoadAsync( Url = url,
stream, UserAgent = USERAGENT,
LoadOptions.PreserveWhitespace, LogErrorResponseBody = true,
cancellationToken).ConfigureAwait(false); BufferContent = false,
}
catch CancellationToken = cancellationToken
};
options.RequestHeaders["FriendlyName.DLNA.ORG"] = FriendlyName;
using (var response = await _httpClient.SendAsync(options, HttpMethod.Get).ConfigureAwait(false))
using (var stream = response.Content)
using (var reader = new StreamReader(stream, Encoding.UTF8))
{ {
return null; return XDocument.Parse(
await reader.ReadToEndAsync().ConfigureAwait(false),
LoadOptions.PreserveWhitespace);
} }
} }
private async Task<HttpResponseMessage> PostSoapDataAsync( private Task<HttpResponseInfo> PostSoapDataAsync(
string url, string url,
string soapAction, string soapAction,
string postData, string postData,
@@ -119,20 +130,29 @@ namespace Emby.Dlna.PlayTo
soapAction = $"\"{soapAction}\""; soapAction = $"\"{soapAction}\"";
} }
using var options = new HttpRequestMessage(HttpMethod.Post, url); var options = new HttpRequestOptions
options.Headers.UserAgent.ParseAdd(USERAGENT); {
options.Headers.TryAddWithoutValidation("SOAPACTION", soapAction); Url = url,
options.Headers.TryAddWithoutValidation("Pragma", "no-cache"); UserAgent = USERAGENT,
options.Headers.TryAddWithoutValidation("FriendlyName.DLNA.ORG", FriendlyName); LogErrorResponseBody = true,
BufferContent = false,
CancellationToken = cancellationToken
};
options.RequestHeaders["SOAPAction"] = soapAction;
options.RequestHeaders["Pragma"] = "no-cache";
options.RequestHeaders["FriendlyName.DLNA.ORG"] = FriendlyName;
if (!string.IsNullOrEmpty(header)) if (!string.IsNullOrEmpty(header))
{ {
options.Headers.TryAddWithoutValidation("contentFeatures.dlna.org", header); options.RequestHeaders["contentFeatures.dlna.org"] = header;
} }
options.Content = new StringContent(postData, Encoding.UTF8, MediaTypeNames.Text.Xml); options.RequestContentType = "text/xml";
options.RequestContent = postData;
return await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); return _httpClient.Post(options);
} }
} }
} }
+13
View File
@@ -0,0 +1,13 @@
#pragma warning disable CS1591
namespace Emby.Dlna.PlayTo
{
public enum TRANSPORTSTATE
{
STOPPED,
PLAYING,
TRANSITIONING,
PAUSED_PLAYBACK,
PAUSED
}
}
+48 -38
View File
@@ -2,7 +2,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Xml.Linq; using System.Xml.Linq;
using Emby.Dlna.Common; using Emby.Dlna.Common;
@@ -12,28 +11,36 @@ namespace Emby.Dlna.PlayTo
{ {
public class TransportCommands public class TransportCommands
{ {
private const string CommandBase = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + "<SOAP-ENV:Body>" + "<m:{0} xmlns:m=\"{1}\">" + "{2}" + "</m:{0}>" + "</SOAP-ENV:Body></SOAP-ENV:Envelope>"; private List<StateVariable> _stateVariables = new List<StateVariable>();
public List<StateVariable> StateVariables
{
get => _stateVariables;
set => _stateVariables = value;
}
public List<StateVariable> StateVariables { get; } = new List<StateVariable>(); private List<ServiceAction> _serviceActions = new List<ServiceAction>();
public List<ServiceAction> ServiceActions
public List<ServiceAction> ServiceActions { get; } = new List<ServiceAction>(); {
get => _serviceActions;
set => _serviceActions = value;
}
public static TransportCommands Create(XDocument document) public static TransportCommands Create(XDocument document)
{ {
var command = new TransportCommands(); var command = new TransportCommands();
var actionList = document.Descendants(UPnpNamespaces.Svc + "actionList"); var actionList = document.Descendants(uPnpNamespaces.svc + "actionList");
foreach (var container in actionList.Descendants(UPnpNamespaces.Svc + "action")) foreach (var container in actionList.Descendants(uPnpNamespaces.svc + "action"))
{ {
command.ServiceActions.Add(ServiceActionFromXml(container)); command.ServiceActions.Add(ServiceActionFromXml(container));
} }
var stateValues = document.Descendants(UPnpNamespaces.ServiceStateTable).FirstOrDefault(); var stateValues = document.Descendants(uPnpNamespaces.ServiceStateTable).FirstOrDefault();
if (stateValues != null) if (stateValues != null)
{ {
foreach (var container in stateValues.Elements(UPnpNamespaces.Svc + "stateVariable")) foreach (var container in stateValues.Elements(uPnpNamespaces.svc + "stateVariable"))
{ {
command.StateVariables.Add(FromXml(container)); command.StateVariables.Add(FromXml(container));
} }
@@ -44,19 +51,19 @@ namespace Emby.Dlna.PlayTo
private static ServiceAction ServiceActionFromXml(XElement container) private static ServiceAction ServiceActionFromXml(XElement container)
{ {
var serviceAction = new ServiceAction var argumentList = new List<Argument>();
{
Name = container.GetValue(UPnpNamespaces.Svc + "name"),
};
var argumentList = serviceAction.ArgumentList; foreach (var arg in container.Descendants(uPnpNamespaces.svc + "argument"))
foreach (var arg in container.Descendants(UPnpNamespaces.Svc + "argument"))
{ {
argumentList.Add(ArgumentFromXml(arg)); argumentList.Add(ArgumentFromXml(arg));
} }
return serviceAction; return new ServiceAction
{
Name = container.GetValue(uPnpNamespaces.svc + "name"),
ArgumentList = argumentList
};
} }
private static Argument ArgumentFromXml(XElement container) private static Argument ArgumentFromXml(XElement container)
@@ -68,30 +75,30 @@ namespace Emby.Dlna.PlayTo
return new Argument return new Argument
{ {
Name = container.GetValue(UPnpNamespaces.Svc + "name"), Name = container.GetValue(uPnpNamespaces.svc + "name"),
Direction = container.GetValue(UPnpNamespaces.Svc + "direction"), Direction = container.GetValue(uPnpNamespaces.svc + "direction"),
RelatedStateVariable = container.GetValue(UPnpNamespaces.Svc + "relatedStateVariable") RelatedStateVariable = container.GetValue(uPnpNamespaces.svc + "relatedStateVariable")
}; };
} }
private static StateVariable FromXml(XElement container) private static StateVariable FromXml(XElement container)
{ {
var allowedValues = Array.Empty<string>(); var allowedValues = new List<string>();
var element = container.Descendants(UPnpNamespaces.Svc + "allowedValueList") var element = container.Descendants(uPnpNamespaces.svc + "allowedValueList")
.FirstOrDefault(); .FirstOrDefault();
if (element != null) if (element != null)
{ {
var values = element.Descendants(UPnpNamespaces.Svc + "allowedValue"); var values = element.Descendants(uPnpNamespaces.svc + "allowedValue");
allowedValues = values.Select(child => child.Value).ToArray(); allowedValues.AddRange(values.Select(child => child.Value));
} }
return new StateVariable return new StateVariable
{ {
Name = container.GetValue(UPnpNamespaces.Svc + "name"), Name = container.GetValue(uPnpNamespaces.svc + "name"),
DataType = container.GetValue(UPnpNamespaces.Svc + "dataType"), DataType = container.GetValue(uPnpNamespaces.svc + "dataType"),
AllowedValues = allowedValues AllowedValues = allowedValues.ToArray()
}; };
} }
@@ -101,12 +108,12 @@ namespace Emby.Dlna.PlayTo
foreach (var arg in action.ArgumentList) foreach (var arg in action.ArgumentList)
{ {
if (string.Equals(arg.Direction, "out", StringComparison.Ordinal)) if (arg.Direction == "out")
{ {
continue; continue;
} }
if (string.Equals(arg.Name, "InstanceID", StringComparison.Ordinal)) if (arg.Name == "InstanceID")
{ {
stateString += BuildArgumentXml(arg, "0"); stateString += BuildArgumentXml(arg, "0");
} }
@@ -116,7 +123,7 @@ namespace Emby.Dlna.PlayTo
} }
} }
return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamespace, stateString); return string.Format(CommandBase, action.Name, xmlNamespace, stateString);
} }
public string BuildPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "") public string BuildPost(ServiceAction action, string xmlNamesapce, object value, string commandParameter = "")
@@ -125,12 +132,12 @@ namespace Emby.Dlna.PlayTo
foreach (var arg in action.ArgumentList) foreach (var arg in action.ArgumentList)
{ {
if (string.Equals(arg.Direction, "out", StringComparison.Ordinal)) if (arg.Direction == "out")
{ {
continue; continue;
} }
if (string.Equals(arg.Name, "InstanceID", StringComparison.Ordinal)) if (arg.Name == "InstanceID")
{ {
stateString += BuildArgumentXml(arg, "0"); stateString += BuildArgumentXml(arg, "0");
} }
@@ -140,7 +147,7 @@ namespace Emby.Dlna.PlayTo
} }
} }
return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamesapce, stateString); return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
} }
public string BuildPost(ServiceAction action, string xmlNamesapce, object value, Dictionary<string, string> dictionary) public string BuildPost(ServiceAction action, string xmlNamesapce, object value, Dictionary<string, string> dictionary)
@@ -149,7 +156,7 @@ namespace Emby.Dlna.PlayTo
foreach (var arg in action.ArgumentList) foreach (var arg in action.ArgumentList)
{ {
if (string.Equals(arg.Name, "InstanceID", StringComparison.Ordinal)) if (arg.Name == "InstanceID")
{ {
stateString += BuildArgumentXml(arg, "0"); stateString += BuildArgumentXml(arg, "0");
} }
@@ -163,7 +170,7 @@ namespace Emby.Dlna.PlayTo
} }
} }
return string.Format(CultureInfo.InvariantCulture, CommandBase, action.Name, xmlNamesapce, stateString); return string.Format(CommandBase, action.Name, xmlNamesapce, stateString);
} }
private string BuildArgumentXml(Argument argument, string value, string commandParameter = "") private string BuildArgumentXml(Argument argument, string value, string commandParameter = "")
@@ -173,12 +180,15 @@ namespace Emby.Dlna.PlayTo
if (state != null) if (state != null)
{ {
var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ?? var sendValue = state.AllowedValues.FirstOrDefault(a => string.Equals(a, commandParameter, StringComparison.OrdinalIgnoreCase)) ??
(state.AllowedValues.Count > 0 ? state.AllowedValues[0] : value); state.AllowedValues.FirstOrDefault() ??
value;
return string.Format(CultureInfo.InvariantCulture, "<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}</{0}>", argument.Name, state.DataType ?? "string", sendValue); return string.Format("<{0} xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"{1}\">{2}</{0}>", argument.Name, state.DataType ?? "string", sendValue);
} }
return string.Format(CultureInfo.InvariantCulture, "<{0}>{1}</{0}>", argument.Name, value); return string.Format("<{0}>{1}</{0}>", argument.Name, value);
} }
private const string CommandBase = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + "<SOAP-ENV:Body>" + "<m:{0} xmlns:m=\"{1}\">" + "{2}" + "</m:{0}>" + "</SOAP-ENV:Body></SOAP-ENV:Envelope>";
} }
} }
-14
View File
@@ -1,14 +0,0 @@
#pragma warning disable CS1591
#pragma warning disable SA1602
namespace Emby.Dlna.PlayTo
{
public enum TransportState
{
Stopped,
Playing,
Transitioning,
PausedPlayback,
Paused
}
}
+8 -8
View File
@@ -6,22 +6,22 @@ using Emby.Dlna.Ssdp;
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
public class UpnpContainer : UBaseObject public class UpnpContainer : uBaseObject
{ {
public static UBaseObject Create(XElement container) public static uBaseObject Create(XElement container)
{ {
if (container == null) if (container == null)
{ {
throw new ArgumentNullException(nameof(container)); throw new ArgumentNullException(nameof(container));
} }
return new UBaseObject return new uBaseObject
{ {
Id = container.GetAttributeValue(UPnpNamespaces.Id), Id = container.GetAttributeValue(uPnpNamespaces.Id),
ParentId = container.GetAttributeValue(UPnpNamespaces.ParentId), ParentId = container.GetAttributeValue(uPnpNamespaces.ParentId),
Title = container.GetValue(UPnpNamespaces.Title), Title = container.GetValue(uPnpNamespaces.title),
IconUrl = container.GetValue(UPnpNamespaces.Artwork), IconUrl = container.GetValue(uPnpNamespaces.Artwork),
UpnpClass = container.GetValue(UPnpNamespaces.Class) UpnpClass = container.GetValue(uPnpNamespaces.uClass)
}; };
} }
} }
+12 -13
View File
@@ -1,11 +1,10 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
using System.Collections.Generic;
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
public class UBaseObject public class uBaseObject
{ {
public string Id { get; set; } public string Id { get; set; }
@@ -21,10 +20,20 @@ namespace Emby.Dlna.PlayTo
public string Url { get; set; } public string Url { get; set; }
public IReadOnlyList<string> ProtocolInfo { get; set; } public string[] ProtocolInfo { get; set; }
public string UpnpClass { get; set; } public string UpnpClass { get; set; }
public bool Equals(uBaseObject obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
return string.Equals(Id, obj.Id);
}
public string MediaType public string MediaType
{ {
get get
@@ -49,15 +58,5 @@ namespace Emby.Dlna.PlayTo
return null; return null;
} }
} }
public bool Equals(UBaseObject obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
return string.Equals(Id, obj.Id, StringComparison.Ordinal);
}
} }
} }
+30 -56
View File
@@ -4,64 +4,38 @@ using System.Xml.Linq;
namespace Emby.Dlna.PlayTo namespace Emby.Dlna.PlayTo
{ {
public static class UPnpNamespaces public class uPnpNamespaces
{ {
public static XNamespace Dc { get; } = "http://purl.org/dc/elements/1.1/"; public static XNamespace dc = "http://purl.org/dc/elements/1.1/";
public static XNamespace ns = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
public static XNamespace svc = "urn:schemas-upnp-org:service-1-0";
public static XNamespace ud = "urn:schemas-upnp-org:device-1-0";
public static XNamespace upnp = "urn:schemas-upnp-org:metadata-1-0/upnp/";
public static XNamespace RenderingControl = "urn:schemas-upnp-org:service:RenderingControl:1";
public static XNamespace AvTransport = "urn:schemas-upnp-org:service:AVTransport:1";
public static XNamespace ContentDirectory = "urn:schemas-upnp-org:service:ContentDirectory:1";
public static XNamespace Ns { get; } = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"; public static XName containers = ns + "container";
public static XName items = ns + "item";
public static XName title = dc + "title";
public static XName creator = dc + "creator";
public static XName artist = upnp + "artist";
public static XName Id = "id";
public static XName ParentId = "parentID";
public static XName uClass = upnp + "class";
public static XName Artwork = upnp + "albumArtURI";
public static XName Description = dc + "description";
public static XName LongDescription = upnp + "longDescription";
public static XName Album = upnp + "album";
public static XName Author = upnp + "author";
public static XName Director = upnp + "director";
public static XName PlayCount = upnp + "playbackCount";
public static XName Tracknumber = upnp + "originalTrackNumber";
public static XName Res = ns + "res";
public static XName Duration = "duration";
public static XName ProtocolInfo = "protocolInfo";
public static XNamespace Svc { get; } = "urn:schemas-upnp-org:service-1-0"; public static XName ServiceStateTable = svc + "serviceStateTable";
public static XName StateVariable = svc + "stateVariable";
public static XNamespace Ud { get; } = "urn:schemas-upnp-org:device-1-0";
public static XNamespace UPnp { get; } = "urn:schemas-upnp-org:metadata-1-0/upnp/";
public static XNamespace RenderingControl { get; } = "urn:schemas-upnp-org:service:RenderingControl:1";
public static XNamespace AvTransport { get; } = "urn:schemas-upnp-org:service:AVTransport:1";
public static XNamespace ContentDirectory { get; } = "urn:schemas-upnp-org:service:ContentDirectory:1";
public static XName Containers { get; } = Ns + "container";
public static XName Items { get; } = Ns + "item";
public static XName Title { get; } = Dc + "title";
public static XName Creator { get; } = Dc + "creator";
public static XName Artist { get; } = UPnp + "artist";
public static XName Id { get; } = "id";
public static XName ParentId { get; } = "parentID";
public static XName Class { get; } = UPnp + "class";
public static XName Artwork { get; } = UPnp + "albumArtURI";
public static XName Description { get; } = Dc + "description";
public static XName LongDescription { get; } = UPnp + "longDescription";
public static XName Album { get; } = UPnp + "album";
public static XName Author { get; } = UPnp + "author";
public static XName Director { get; } = UPnp + "director";
public static XName PlayCount { get; } = UPnp + "playbackCount";
public static XName Tracknumber { get; } = UPnp + "originalTrackNumber";
public static XName Res { get; } = Ns + "res";
public static XName Duration { get; } = "duration";
public static XName ProtocolInfo { get; } = "protocolInfo";
public static XName ServiceStateTable { get; } = Svc + "serviceStateTable";
public static XName StateVariable { get; } = Svc + "stateVariable";
} }
} }
+2 -5
View File
@@ -1,7 +1,5 @@
#pragma warning disable CS1591 #pragma warning disable CS1591
using System;
using System.Globalization;
using System.Linq; using System.Linq;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
@@ -12,7 +10,6 @@ namespace Emby.Dlna.Profiles
{ {
public DefaultProfile() public DefaultProfile()
{ {
Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
Name = "Generic Device"; Name = "Generic Device";
ProtocolInfo = "http-get:*:video/mpeg:*,http-get:*:video/mp4:*,http-get:*:video/vnd.dlna.mpeg-tts:*,http-get:*:video/avi:*,http-get:*:video/x-matroska:*,http-get:*:video/x-ms-wmv:*,http-get:*:video/wtv:*,http-get:*:audio/mpeg:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/wav:*,http-get:*:audio/L16:*,http-get:*:image/jpeg:*,http-get:*:image/png:*,http-get:*:image/gif:*,http-get:*:image/tiff:*"; ProtocolInfo = "http-get:*:video/mpeg:*,http-get:*:video/mp4:*,http-get:*:video/vnd.dlna.mpeg-tts:*,http-get:*:video/avi:*,http-get:*:video/x-matroska:*,http-get:*:video/x-ms-wmv:*,http-get:*:video/wtv:*,http-get:*:audio/mpeg:*,http-get:*:audio/mp3:*,http-get:*:audio/mp4:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/wav:*,http-get:*:audio/L16:*,http-get:*:image/jpeg:*,http-get:*:image/png:*,http-get:*:image/gif:*,http-get:*:image/tiff:*";
@@ -67,14 +64,14 @@ namespace Emby.Dlna.Profiles
new DirectPlayProfile new DirectPlayProfile
{ {
// play all // play all
Container = string.Empty, Container = "",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new DirectPlayProfile new DirectPlayProfile
{ {
// play all // play all
Container = string.Empty, Container = "",
Type = DlnaProfileType.Audio Type = DlnaProfileType.Audio
} }
}; };
+6 -6
View File
@@ -24,7 +24,7 @@ namespace Emby.Dlna.Profiles
{ {
Match = HeaderMatchType.Substring, Match = HeaderMatchType.Substring,
Name = "User-Agent", Name = "User-Agent",
Value = "Zip_" Value ="Zip_"
} }
} }
}; };
@@ -81,7 +81,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -124,7 +124,7 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -161,7 +161,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3,he-aac", Codec = "ac3,he-aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -177,7 +177,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -192,7 +192,7 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Conditions = new[] Conditions = new []
{ {
// The device does not have any audio switching capabilities // The device does not have any audio switching capabilities
new ProfileCondition new ProfileCondition
+2 -2
View File
@@ -84,7 +84,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -191,7 +191,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new[] ResponseProfiles = new ResponseProfile[]
{ {
new ResponseProfile new ResponseProfile
{ {
+1 -1
View File
@@ -32,7 +32,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new[] ResponseProfiles = new ResponseProfile[]
{ {
new ResponseProfile new ResponseProfile
{ {
+1 -1
View File
@@ -138,7 +138,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+7 -7
View File
@@ -93,8 +93,8 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec="h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition(ProfileConditionType.EqualsAny, ProfileConditionValue.VideoProfile, "baseline|constrained baseline"), new ProfileCondition(ProfileConditionType.EqualsAny, ProfileConditionValue.VideoProfile, "baseline|constrained baseline"),
new ProfileCondition new ProfileCondition
@@ -122,7 +122,7 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -150,7 +150,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -166,7 +166,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Audio, Type = CodecType.Audio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -182,7 +182,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Audio, Type = CodecType.Audio,
Codec = "mp3", Codec = "mp3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -202,7 +202,7 @@ namespace Emby.Dlna.Profiles
} }
}; };
ResponseProfiles = new[] ResponseProfiles = new ResponseProfile[]
{ {
new ResponseProfile new ResponseProfile
{ {
+1 -1
View File
@@ -139,7 +139,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+3 -3
View File
@@ -150,7 +150,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -178,7 +178,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -197,7 +197,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+3 -3
View File
@@ -150,7 +150,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -178,7 +178,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -197,7 +197,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+3 -3
View File
@@ -138,7 +138,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -166,7 +166,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -185,7 +185,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+3 -3
View File
@@ -138,7 +138,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -166,7 +166,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -185,7 +185,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -114,7 +114,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -156,7 +156,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -172,7 +172,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -191,7 +191,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -217,7 +217,7 @@ namespace Emby.Dlna.Profiles
VideoCodec = "h264,mpeg4,vc1", VideoCodec = "h264,mpeg4,vc1",
AudioCodec = "ac3,aac,mp3", AudioCodec = "ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO", OrgPn="MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
+22 -22
View File
@@ -102,13 +102,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T", OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -128,13 +128,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO", OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -148,28 +148,28 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU", OrgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "mpeg2video", VideoCodec="mpeg2video",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO", OrgPn="MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "mpeg", Container = "mpeg",
VideoCodec = "mpeg1video,mpeg2video", VideoCodec="mpeg1video,mpeg2video",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "MPEG_PS_NTSC,MPEG_PS_PAL", OrgPn="MPEG_PS_NTSC,MPEG_PS_PAL",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
} }
}; };
@@ -180,7 +180,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -204,7 +204,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -243,7 +243,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "mpeg2video", Codec = "mpeg2video",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -275,7 +275,7 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -303,7 +303,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -319,7 +319,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -341,7 +341,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "mp3,mp2", Codec = "mp3,mp2",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+21 -21
View File
@@ -120,7 +120,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -143,13 +143,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T", OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -169,13 +169,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO", OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -189,28 +189,28 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU", OrgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "mpeg2video", VideoCodec="mpeg2video",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO", OrgPn="MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "mpeg", Container = "mpeg",
VideoCodec = "mpeg1video,mpeg2video", VideoCodec="mpeg1video,mpeg2video",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "MPEG_PS_NTSC,MPEG_PS_PAL", OrgPn="MPEG_PS_NTSC,MPEG_PS_PAL",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
@@ -227,7 +227,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -266,7 +266,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "mpeg2video", Codec = "mpeg2video",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -298,7 +298,7 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -326,7 +326,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -364,7 +364,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "mp3,mp2", Codec = "mp3,mp2",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+17 -17
View File
@@ -131,13 +131,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T", OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -157,13 +157,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO", OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -177,28 +177,28 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU", OrgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "mpeg2video", VideoCodec="mpeg2video",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO", OrgPn="MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "mpeg", Container = "mpeg",
VideoCodec = "mpeg1video,mpeg2video", VideoCodec="mpeg1video,mpeg2video",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "MPEG_PS_NTSC,MPEG_PS_PAL", OrgPn="MPEG_PS_NTSC,MPEG_PS_PAL",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
@@ -215,7 +215,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -282,7 +282,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "mp3,mp2", Codec = "mp3,mp2",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+19 -18
View File
@@ -164,7 +164,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -187,13 +187,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T", OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -213,13 +213,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO", OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -233,28 +233,28 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU", OrgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "mpeg2video", VideoCodec="mpeg2video",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO", OrgPn="MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "mpeg", Container = "mpeg",
VideoCodec = "mpeg1video,mpeg2video", VideoCodec="mpeg1video,mpeg2video",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "MPEG_PS_NTSC,MPEG_PS_PAL", OrgPn="MPEG_PS_NTSC,MPEG_PS_PAL",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
@@ -265,13 +265,14 @@ namespace Emby.Dlna.Profiles
} }
}; };
CodecProfiles = new[] CodecProfiles = new[]
{ {
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -299,7 +300,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "mp3,mp2", Codec = "mp3,mp2",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+19 -18
View File
@@ -164,7 +164,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -187,13 +187,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T", OrgPn="AVC_TS_HD_24_AC3_T,AVC_TS_HD_50_AC3_T,AVC_TS_HD_60_AC3_T,AVC_TS_HD_EU_T",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -213,13 +213,13 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO", OrgPn="AVC_TS_HD_24_AC3_ISO,AVC_TS_HD_50_AC3_ISO,AVC_TS_HD_60_AC3_ISO,AVC_TS_HD_EU_ISO",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -233,28 +233,28 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "h264", VideoCodec="h264",
AudioCodec = "ac3,aac,mp3", AudioCodec="ac3,aac,mp3",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU", OrgPn="AVC_TS_HD_24_AC3,AVC_TS_HD_50_AC3,AVC_TS_HD_60_AC3,AVC_TS_HD_EU",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "ts,mpegts", Container = "ts,mpegts",
VideoCodec = "mpeg2video", VideoCodec="mpeg2video",
MimeType = "video/vnd.dlna.mpeg-tts", MimeType = "video/vnd.dlna.mpeg-tts",
OrgPn = "MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO", OrgPn="MPEG_TS_SD_EU,MPEG_TS_SD_NA,MPEG_TS_SD_KO",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
{ {
Container = "mpeg", Container = "mpeg",
VideoCodec = "mpeg1video,mpeg2video", VideoCodec="mpeg1video,mpeg2video",
MimeType = "video/mpeg", MimeType = "video/mpeg",
OrgPn = "MPEG_PS_NTSC,MPEG_PS_PAL", OrgPn="MPEG_PS_NTSC,MPEG_PS_PAL",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new ResponseProfile new ResponseProfile
@@ -265,13 +265,14 @@ namespace Emby.Dlna.Profiles
} }
}; };
CodecProfiles = new[] CodecProfiles = new[]
{ {
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -299,7 +300,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "mp3,mp2", Codec = "mp3,mp2",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+9 -9
View File
@@ -52,7 +52,7 @@ namespace Emby.Dlna.Profiles
Container = "ts,mpegts", Container = "ts,mpegts",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
VideoCodec = "mpeg1video,mpeg2video,h264", VideoCodec = "mpeg1video,mpeg2video,h264",
AudioCodec = "aac,ac3,mp2" AudioCodec = "ac3,mp2,mp3,aac"
}, },
new DirectPlayProfile new DirectPlayProfile
{ {
@@ -92,7 +92,7 @@ namespace Emby.Dlna.Profiles
{ {
Container = "ts", Container = "ts",
VideoCodec = "h264", VideoCodec = "h264",
AudioCodec = "aac,ac3,mp2", AudioCodec = "ac3,aac,mp3",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new TranscodingProfile new TranscodingProfile
@@ -108,7 +108,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -133,7 +133,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -176,7 +176,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -201,7 +201,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "wmapro", Codec = "wmapro",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -217,7 +217,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -235,7 +235,7 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "mp4,mov", Container = "mp4,mov",
AudioCodec = "aac", AudioCodec="aac",
MimeType = "video/mp4", MimeType = "video/mp4",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
@@ -244,7 +244,7 @@ namespace Emby.Dlna.Profiles
{ {
Container = "avi", Container = "avi",
MimeType = "video/divx", MimeType = "video/divx",
OrgPn = "AVI", OrgPn="AVI",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
+9 -9
View File
@@ -52,7 +52,7 @@ namespace Emby.Dlna.Profiles
Container = "ts,mpegts", Container = "ts,mpegts",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
VideoCodec = "mpeg1video,mpeg2video,h264", VideoCodec = "mpeg1video,mpeg2video,h264",
AudioCodec = "aac,ac3,mp2" AudioCodec = "ac3,mp2,mp3,aac"
}, },
new DirectPlayProfile new DirectPlayProfile
{ {
@@ -94,7 +94,7 @@ namespace Emby.Dlna.Profiles
{ {
Container = "ts", Container = "ts",
VideoCodec = "h264", VideoCodec = "h264",
AudioCodec = "aac,ac3,mp2", AudioCodec = "mp3",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
new TranscodingProfile new TranscodingProfile
@@ -110,7 +110,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -135,7 +135,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -178,7 +178,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3", Codec = "ac3",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -203,7 +203,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "wmapro", Codec = "wmapro",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -219,7 +219,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -237,7 +237,7 @@ namespace Emby.Dlna.Profiles
new ResponseProfile new ResponseProfile
{ {
Container = "mp4,mov", Container = "mp4,mov",
AudioCodec = "aac", AudioCodec="aac",
MimeType = "video/mp4", MimeType = "video/mp4",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
@@ -246,7 +246,7 @@ namespace Emby.Dlna.Profiles
{ {
Container = "avi", Container = "avi",
MimeType = "video/divx", MimeType = "video/divx",
OrgPn = "AVI", OrgPn="AVI",
Type = DlnaProfileType.Video Type = DlnaProfileType.Video
}, },
+4 -4
View File
@@ -20,7 +20,7 @@ namespace Emby.Dlna.Profiles
Headers = new[] Headers = new[]
{ {
new HttpHeaderInfo { Name = "User-Agent", Value = "alphanetworks", Match = HeaderMatchType.Substring }, new HttpHeaderInfo {Name = "User-Agent", Value = "alphanetworks", Match = HeaderMatchType.Substring},
new HttpHeaderInfo new HttpHeaderInfo
{ {
Name = "User-Agent", Name = "User-Agent",
@@ -168,7 +168,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = DlnaProfileType.Photo, Type = DlnaProfileType.Photo,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -193,7 +193,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -221,7 +221,7 @@ namespace Emby.Dlna.Profiles
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
+7 -7
View File
@@ -119,7 +119,7 @@ namespace Emby.Dlna.Profiles
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
Container = "mp4,mov", Container = "mp4,mov",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -138,7 +138,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "mpeg4", Codec = "mpeg4",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -187,7 +187,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "h264", Codec = "h264",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -236,7 +236,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.Video, Type = CodecType.Video,
Codec = "wmv2,wmv3,vc1", Codec = "wmv2,wmv3,vc1",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -284,7 +284,7 @@ namespace Emby.Dlna.Profiles
new CodecProfile new CodecProfile
{ {
Type = CodecType.Video, Type = CodecType.Video,
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -307,7 +307,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "ac3,wmav2,wmapro", Codec = "ac3,wmav2,wmapro",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -323,7 +323,7 @@ namespace Emby.Dlna.Profiles
{ {
Type = CodecType.VideoAudio, Type = CodecType.VideoAudio,
Codec = "aac", Codec = "aac",
Conditions = new[] Conditions = new []
{ {
new ProfileCondition new ProfileCondition
{ {
@@ -38,7 +38,7 @@
<XmlRootAttributes /> <XmlRootAttributes />
<DirectPlayProfiles> <DirectPlayProfiles>
<DirectPlayProfile container="avi" audioCodec="mp2,mp3" videoCodec="mpeg4" type="Video" /> <DirectPlayProfile container="avi" audioCodec="mp2,mp3" videoCodec="mpeg4" type="Video" />
<DirectPlayProfile container="ts,mpegts" audioCodec="aac,ac3,mp2" videoCodec="mpeg1video,mpeg2video,h264" type="Video" /> <DirectPlayProfile container="ts,mpegts" audioCodec="ac3,mp2,mp3,aac" videoCodec="mpeg1video,mpeg2video,h264" type="Video" />
<DirectPlayProfile container="mpeg" audioCodec="mp2" videoCodec="mpeg1video,mpeg2video" type="Video" /> <DirectPlayProfile container="mpeg" audioCodec="mp2" videoCodec="mpeg1video,mpeg2video" type="Video" />
<DirectPlayProfile container="mp4" audioCodec="aac,ac3" videoCodec="h264,mpeg4" type="Video" /> <DirectPlayProfile container="mp4" audioCodec="aac,ac3" videoCodec="h264,mpeg4" type="Video" />
<DirectPlayProfile container="aac,mp3,wav" type="Audio" /> <DirectPlayProfile container="aac,mp3,wav" type="Audio" />
@@ -46,7 +46,7 @@
</DirectPlayProfiles> </DirectPlayProfiles>
<TranscodingProfiles> <TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" /> <TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac,ac3,mp2" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" /> <TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="ac3,aac,mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" /> <TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" />
</TranscodingProfiles> </TranscodingProfiles>
<ContainerProfiles> <ContainerProfiles>
@@ -38,7 +38,7 @@
<XmlRootAttributes /> <XmlRootAttributes />
<DirectPlayProfiles> <DirectPlayProfiles>
<DirectPlayProfile container="avi" audioCodec="mp2,mp3" videoCodec="mpeg4" type="Video" /> <DirectPlayProfile container="avi" audioCodec="mp2,mp3" videoCodec="mpeg4" type="Video" />
<DirectPlayProfile container="ts,mpegts" audioCodec="aac,ac3,mp2" videoCodec="mpeg1video,mpeg2video,h264" type="Video" /> <DirectPlayProfile container="ts,mpegts" audioCodec="ac3,mp2,mp3,aac" videoCodec="mpeg1video,mpeg2video,h264" type="Video" />
<DirectPlayProfile container="mpeg" audioCodec="mp2" videoCodec="mpeg1video,mpeg2video" type="Video" /> <DirectPlayProfile container="mpeg" audioCodec="mp2" videoCodec="mpeg1video,mpeg2video" type="Video" />
<DirectPlayProfile container="mp4,mkv,m4v" audioCodec="aac,ac3" videoCodec="h264,mpeg4" type="Video" /> <DirectPlayProfile container="mp4,mkv,m4v" audioCodec="aac,ac3" videoCodec="h264,mpeg4" type="Video" />
<DirectPlayProfile container="aac,mp3,wav" type="Audio" /> <DirectPlayProfile container="aac,mp3,wav" type="Audio" />
@@ -46,7 +46,7 @@
</DirectPlayProfiles> </DirectPlayProfiles>
<TranscodingProfiles> <TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Bytes" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" /> <TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Bytes" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="aac,ac3,mp2" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" /> <TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" /> <TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" minSegments="0" segmentLength="0" breakOnNonKeyFrames="false" />
</TranscodingProfiles> </TranscodingProfiles>
<ContainerProfiles> <ContainerProfiles>
-2
View File
@@ -1,6 +1,5 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
using System.Runtime.CompilerServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
@@ -14,7 +13,6 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]
[assembly: InternalsVisibleTo("Jellyfin.Dlna.Tests")]
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
+119 -71
View File
@@ -4,7 +4,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Security;
using System.Text; using System.Text;
using Emby.Dlna.Common; using Emby.Dlna.Common;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
@@ -40,6 +39,8 @@ namespace Emby.Dlna.Server
_serverId = serverId; _serverId = serverId;
} }
private static bool EnableAbsoluteUrls => false;
public string GetXml() public string GetXml()
{ {
var builder = new StringBuilder(); var builder = new StringBuilder();
@@ -63,16 +64,21 @@ namespace Emby.Dlna.Server
foreach (var att in attributes) foreach (var att in attributes)
{ {
builder.AppendFormat(CultureInfo.InvariantCulture, " {0}=\"{1}\"", att.Name, att.Value); builder.AppendFormat(" {0}=\"{1}\"", att.Name, att.Value);
} }
builder.Append('>'); builder.Append(">");
builder.Append("<specVersion>"); builder.Append("<specVersion>");
builder.Append("<major>1</major>"); builder.Append("<major>1</major>");
builder.Append("<minor>0</minor>"); builder.Append("<minor>0</minor>");
builder.Append("</specVersion>"); builder.Append("</specVersion>");
if (!EnableAbsoluteUrls)
{
builder.Append("<URLBase>" + Escape(_serverAddress) + "</URLBase>");
}
AppendDeviceInfo(builder); AppendDeviceInfo(builder);
builder.Append("</root>"); builder.Append("</root>");
@@ -87,14 +93,91 @@ namespace Emby.Dlna.Server
AppendIconList(builder); AppendIconList(builder);
builder.Append("<presentationURL>") builder.Append("<presentationURL>" + Escape(_serverAddress) + "/web/index.html</presentationURL>");
.Append(SecurityElement.Escape(_serverAddress))
.Append("/web/index.html</presentationURL>");
AppendServiceList(builder); AppendServiceList(builder);
builder.Append("</device>"); builder.Append("</device>");
} }
private static readonly char[] s_escapeChars = new char[]
{
'<',
'>',
'"',
'\'',
'&'
};
private static readonly string[] s_escapeStringPairs = new[]
{
"<",
"&lt;",
">",
"&gt;",
"\"",
"&quot;",
"'",
"&apos;",
"&",
"&amp;"
};
private static string GetEscapeSequence(char c)
{
int num = s_escapeStringPairs.Length;
for (int i = 0; i < num; i += 2)
{
string text = s_escapeStringPairs[i];
string result = s_escapeStringPairs[i + 1];
if (text[0] == c)
{
return result;
}
}
return c.ToString(CultureInfo.InvariantCulture);
}
/// <summary>Replaces invalid XML characters in a string with their valid XML equivalent.</summary>
/// <returns>The input string with invalid characters replaced.</returns>
/// <param name="str">The string within which to escape invalid characters. </param>
public static string Escape(string str)
{
if (str == null)
{
return null;
}
StringBuilder stringBuilder = null;
int length = str.Length;
int num = 0;
while (true)
{
int num2 = str.IndexOfAny(s_escapeChars, num);
if (num2 == -1)
{
break;
}
if (stringBuilder == null)
{
stringBuilder = new StringBuilder();
}
stringBuilder.Append(str, num, num2 - num);
stringBuilder.Append(GetEscapeSequence(str[num2]));
num = num2 + 1;
}
if (stringBuilder == null)
{
return str;
}
stringBuilder.Append(str, num, length - num);
return stringBuilder.ToString();
}
private void AppendDeviceProperties(StringBuilder builder) private void AppendDeviceProperties(StringBuilder builder)
{ {
builder.Append("<dlna:X_DLNACAP/>"); builder.Append("<dlna:X_DLNACAP/>");
@@ -104,54 +187,32 @@ namespace Emby.Dlna.Server
builder.Append("<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>"); builder.Append("<deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>");
builder.Append("<friendlyName>") builder.Append("<friendlyName>" + Escape(GetFriendlyName()) + "</friendlyName>");
.Append(SecurityElement.Escape(GetFriendlyName())) builder.Append("<manufacturer>" + Escape(_profile.Manufacturer ?? string.Empty) + "</manufacturer>");
.Append("</friendlyName>"); builder.Append("<manufacturerURL>" + Escape(_profile.ManufacturerUrl ?? string.Empty) + "</manufacturerURL>");
builder.Append("<manufacturer>")
.Append(SecurityElement.Escape(_profile.Manufacturer ?? string.Empty))
.Append("</manufacturer>");
builder.Append("<manufacturerURL>")
.Append(SecurityElement.Escape(_profile.ManufacturerUrl ?? string.Empty))
.Append("</manufacturerURL>");
builder.Append("<modelDescription>") builder.Append("<modelDescription>" + Escape(_profile.ModelDescription ?? string.Empty) + "</modelDescription>");
.Append(SecurityElement.Escape(_profile.ModelDescription ?? string.Empty)) builder.Append("<modelName>" + Escape(_profile.ModelName ?? string.Empty) + "</modelName>");
.Append("</modelDescription>");
builder.Append("<modelName>")
.Append(SecurityElement.Escape(_profile.ModelName ?? string.Empty))
.Append("</modelName>");
builder.Append("<modelNumber>") builder.Append("<modelNumber>" + Escape(_profile.ModelNumber ?? string.Empty) + "</modelNumber>");
.Append(SecurityElement.Escape(_profile.ModelNumber ?? string.Empty)) builder.Append("<modelURL>" + Escape(_profile.ModelUrl ?? string.Empty) + "</modelURL>");
.Append("</modelNumber>");
builder.Append("<modelURL>")
.Append(SecurityElement.Escape(_profile.ModelUrl ?? string.Empty))
.Append("</modelURL>");
if (string.IsNullOrEmpty(_profile.SerialNumber)) if (string.IsNullOrEmpty(_profile.SerialNumber))
{ {
builder.Append("<serialNumber>") builder.Append("<serialNumber>" + Escape(_serverId) + "</serialNumber>");
.Append(SecurityElement.Escape(_serverId))
.Append("</serialNumber>");
} }
else else
{ {
builder.Append("<serialNumber>") builder.Append("<serialNumber>" + Escape(_profile.SerialNumber) + "</serialNumber>");
.Append(SecurityElement.Escape(_profile.SerialNumber))
.Append("</serialNumber>");
} }
builder.Append("<UPC/>"); builder.Append("<UPC/>");
builder.Append("<UDN>uuid:") builder.Append("<UDN>uuid:" + Escape(_serverUdn) + "</UDN>");
.Append(SecurityElement.Escape(_serverUdn))
.Append("</UDN>");
if (!string.IsNullOrEmpty(_profile.SonyAggregationFlags)) if (!string.IsNullOrEmpty(_profile.SonyAggregationFlags))
{ {
builder.Append("<av:aggregationFlags xmlns:av=\"urn:schemas-sony-com:av\">") builder.Append("<av:aggregationFlags xmlns:av=\"urn:schemas-sony-com:av\">" + Escape(_profile.SonyAggregationFlags) + "</av:aggregationFlags>");
.Append(SecurityElement.Escape(_profile.SonyAggregationFlags))
.Append("</av:aggregationFlags>");
} }
} }
@@ -189,21 +250,11 @@ namespace Emby.Dlna.Server
{ {
builder.Append("<icon>"); builder.Append("<icon>");
builder.Append("<mimetype>") builder.Append("<mimetype>" + Escape(icon.MimeType ?? string.Empty) + "</mimetype>");
.Append(SecurityElement.Escape(icon.MimeType ?? string.Empty)) builder.Append("<width>" + Escape(icon.Width.ToString(_usCulture)) + "</width>");
.Append("</mimetype>"); builder.Append("<height>" + Escape(icon.Height.ToString(_usCulture)) + "</height>");
builder.Append("<width>") builder.Append("<depth>" + Escape(icon.Depth ?? string.Empty) + "</depth>");
.Append(SecurityElement.Escape(icon.Width.ToString(_usCulture))) builder.Append("<url>" + BuildUrl(icon.Url) + "</url>");
.Append("</width>");
builder.Append("<height>")
.Append(SecurityElement.Escape(icon.Height.ToString(_usCulture)))
.Append("</height>");
builder.Append("<depth>")
.Append(SecurityElement.Escape(icon.Depth ?? string.Empty))
.Append("</depth>");
builder.Append("<url>")
.Append(BuildUrl(icon.Url))
.Append("</url>");
builder.Append("</icon>"); builder.Append("</icon>");
} }
@@ -219,21 +270,11 @@ namespace Emby.Dlna.Server
{ {
builder.Append("<service>"); builder.Append("<service>");
builder.Append("<serviceType>") builder.Append("<serviceType>" + Escape(service.ServiceType ?? string.Empty) + "</serviceType>");
.Append(SecurityElement.Escape(service.ServiceType ?? string.Empty)) builder.Append("<serviceId>" + Escape(service.ServiceId ?? string.Empty) + "</serviceId>");
.Append("</serviceType>"); builder.Append("<SCPDURL>" + BuildUrl(service.ScpdUrl) + "</SCPDURL>");
builder.Append("<serviceId>") builder.Append("<controlURL>" + BuildUrl(service.ControlUrl) + "</controlURL>");
.Append(SecurityElement.Escape(service.ServiceId ?? string.Empty)) builder.Append("<eventSubURL>" + BuildUrl(service.EventSubUrl) + "</eventSubURL>");
.Append("</serviceId>");
builder.Append("<SCPDURL>")
.Append(BuildUrl(service.ScpdUrl))
.Append("</SCPDURL>");
builder.Append("<controlURL>")
.Append(BuildUrl(service.ControlUrl))
.Append("</controlURL>");
builder.Append("<eventSubURL>")
.Append(BuildUrl(service.EventSubUrl))
.Append("</eventSubURL>");
builder.Append("</service>"); builder.Append("</service>");
} }
@@ -248,9 +289,16 @@ namespace Emby.Dlna.Server
return string.Empty; return string.Empty;
} }
url = _serverAddress.TrimEnd('/') + "/dlna/" + _serverUdn + "/" + url.TrimStart('/'); url = url.TrimStart('/');
return SecurityElement.Escape(url); url = "/dlna/" + _serverUdn + "/" + url;
if (EnableAbsoluteUrls)
{
url = _serverAddress.TrimEnd('/') + url;
}
return Escape(url);
} }
private IEnumerable<DeviceIcon> GetIcons() private IEnumerable<DeviceIcon> GetIcons()

Some files were not shown because too many files have changed in this diff Show More