Giter Club home page Giter Club logo

honoo.net.upnp's Introduction

Honoo.Net.UPnP

INTRODUCTION

Simple UPnP. Provides port mapping, DLNA e.g..

PROJECT

Github

https://github.com/LokiHonoo/Honoo.Net.UPnP/

NuGet

https://www.nuget.org/packages/Honoo.Net.UPnP/

USAGE

Namespace

using Honoo.Net;

Example-PortMapping

private static void TestPortMapping()
{
    UPnPRootDevice[] devices = UPnP.Discover(2000, UPnP.URN_UPNP_SERVICE_WAN_IP_CONNECTION_1);
    UPnPRootDevice router = devices[0];
    IUPnPWANIPConnectionService service = router.FindService(UPnP.URN_UPNP_SERVICE_WAN_IP_CONNECTION_1);

    //Console.WriteLine(service.GetNATRSIPStatus());
    //Console.WriteLine(service.GetExternalIPAddress());
    //Console.WriteLine(service.GetStatusInfo());
    //Console.WriteLine(service.GetConnectionTypeInfo());
    //Console.WriteLine(service.GetGenericPortMappingEntry(1));

    try
    {
        _ = service.GetSpecificPortMappingEntry("TCP", 4788);
    }
    catch (Exception)
    {
        service.AddPortMapping("TCP", 4788, IPAddress.Parse("192.168.1.11"), 4788, true, "test", 0);
    }
    UPnPPortMappingEntry entry = service.GetSpecificPortMappingEntry("TCP", 4788);
    Console.WriteLine(entry.Protocol + " " + entry.ExternalPort + " " + entry.InternalClient + ":" + entry.InternalPort);
    service.DeletePortMapping("TCP", 4788);

    Console.ReadKey(true);
}

Example-DLNA

private static void TestDlna()
{
    UPnPRootDevice[] devices = UPnP.Discover(2000, UPnP.URN_UPNP_SERVICE_AV_TRANSPORT_1);
    UPnPRootDevice dlna = devices[0];

    //Console.WriteLine(((IUPnPMediaRendererDevice)dlna.Device).XDlnaDoc);

    IUPnPAVTransportService service = dlna.FindService(UPnP.URN_UPNP_SERVICE_AV_TRANSPORT_1);

    //Console.WriteLine(service.GetDeviceCapabilities(0));
    //Console.WriteLine(service.GetTransportSettings(0));
    //Console.WriteLine(service.GetMediaInfo(0));
    //Console.WriteLine(service.GetPositionInfo(0));
    //Console.WriteLine(service.GetTransportInfo(0));
    //Console.WriteLine(service.GetCurrentTransportActions(0));

    // Need setup firewall. Administrator privileges are required.
    UPnPDlnaServer mediaServer = new UPnPDlnaServer(new Uri("http://192.168.1.10:8080/"));

    //string callbackUrl = server.AddEventSubscriber(UPnPEventUpdated);
    //string sid = service.SetEventSubscription(callbackUrl, 3600);

    string mediaUrl = mediaServer.AddMedia("E:\\Videos\\The Ankha Zone.mp4");
    service.SetAVTransportURI(0, mediaUrl, string.Empty);
    service.Play(0, "1");
    Console.ReadKey(true);
    service.Stop(0);
    mediaServer.Dispose();

    //service.RemoveEventSubscription(sid);
}

LICENSE

This project based on MIT license.

honoo.net.upnp's People

Contributors

lokihonoo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.