开发 Android 流媒体服务器

发布于 2024-10-30 06:10:06 字数 395 浏览 2 评论 0原文

我正在尝试开发一个流媒体 AV 媒体服务器,用于 Android 手机作为客户端。这立即限制了我开发使用 RTSP 的服务器。我精通 Java 编程,并且发现 Netty (Java NIO) 可以用来填补 Java 媒体框架中该协议的巨大空白。我尝试过它,但没有取得真正的成功。我了解 live555,但我的日程很紧,并且不想开始搞乱 C++,因为我对这个主题知之甚少。我已经被这个问题困扰了好几个星期了,但没有什么真正可以证明的。由于 Android 市场上有许多专有应用程序,因此流式传输到 Android 肯定是可能的。有这方面经验和知识的人请告诉我是否有一种简单的方法来实现 RTSP AV 媒体服务器,只需流式传输 .mp4 或 .3gp 和 .mp3 以便与 android 一起使用,而不使用 live555 库。如果没有,我就必须快速掌握 C++。先感谢您。

I am trying to develop a Streaming AV Media Server for use with an Android handset as the client. This instantly puts a constraint on me to develop a server that uses RTSP. I am versed in Java programming and have found that Netty (Java NIO) can be used to fill in the otherwise massive gap in the Java Media Framework for this protocol. I have played around with it and have had no real success. I know about live555 but I’m on a tight schedule and don't really want to start messing around with C++ as I know very little on the subject. I have been stuck on this problem for many weeks and have nothing really to show for it. Streaming to android must be possible as there are numerous proprietary apps on the Android market. Could someone who has experience and knowledge on this subject please let me know if there is a simple way to implement an RTSP AV media server that just streams .mp4 or .3gp and .mp3 for use with android without using the live555 libraries. If not I will just have to quickly get up to speed on C++. Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

独夜无伴 2024-11-06 06:10:06

好的,使用 HTTP 进行流传输就这么简单。

我在 WinXP 上使用 IIS 创建了一个名为“音乐”的虚拟文件夹,并将其指向包含 mp3 文件的文件夹。这是传输文件所需的完整活动(名称硬编码)。

顺便说一句,它被称为 SimpleNetRadio,因为我最初开始使用 Shoutcast 流。

package com.mycompany.SimpleNetRadio;

import android.app.Activity;
import android.media.AsyncPlayer;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;

public class SimpleNetRadio extends Activity
{
    private AsyncPlayer ap = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected void onStart() {
        super.onStart();
        ap = (AsyncPlayer) getLastNonConfigurationInstance();
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (ap != null)
            ap.stop();
    }

    @Override
    protected void onResume() {
        super.onResume();

        if (ap == null) {
            ap = new AsyncPlayer("Simple Player");
            ap.play(this, Uri.parse("http://192.168.1.1/Music/02%20-%20Don't%20Stop%20Believin'.mp3"), true, AudioManager.STREAM_MUSIC);
        }
    }

    @Override
    public Object onRetainNonConfigurationInstance() {
        return ap;
    }
}

您还应该能够使用 MediaPlayer 使用更多代码来完成此操作 - 它可以更好地处理错误情况并且不需要更多的工作。

OK, simple as this to stream using HTTP.

I created a virtual folder called 'Music' with IIS on WinXP and pointed it at a folder containing mp3 files. This is the complete Activity needed to stream a file (name hard-coded).

BTW, it's called SimpleNetRadio as I originally started playing around with Shoutcast streams.

package com.mycompany.SimpleNetRadio;

import android.app.Activity;
import android.media.AsyncPlayer;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;

public class SimpleNetRadio extends Activity
{
    private AsyncPlayer ap = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected void onStart() {
        super.onStart();
        ap = (AsyncPlayer) getLastNonConfigurationInstance();
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (ap != null)
            ap.stop();
    }

    @Override
    protected void onResume() {
        super.onResume();

        if (ap == null) {
            ap = new AsyncPlayer("Simple Player");
            ap.play(this, Uri.parse("http://192.168.1.1/Music/02%20-%20Don't%20Stop%20Believin'.mp3"), true, AudioManager.STREAM_MUSIC);
        }
    }

    @Override
    public Object onRetainNonConfigurationInstance() {
        return ap;
    }
}

You should also be able to do this with MediaPlayer with a bit more code - it would handle error conditions better and wouldn't require much more work.

早茶月光 2024-11-06 06:10:06

使用 Netty 开发 RTSP 流媒体服务器是相当简单的任务,并且不需要花费太多时间。我自己写了它,它很有魅力。您可以查看其他一些使用 Netty 框架的服务器的示例实现来开始。

Developing a RTSP streaming server with Netty is fairly straight forward task and doesn't take much of time. I myself have written it and it worked like a charm. You could look at the sample implementations of some other servers using Netty framework to get started.

任谁 2024-11-06 06:10:06

我不确定您的具体需求是什么,但对于静态文件,您可以尝试结合使用 Amazon S3 和 CloudFront,我相信它支持 RTSP。

I'm not sure what your specific needs are, but for static files you might try combining Amazon S3 and CloudFront, which I believe supports RTSP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文