创建Process api查询 [英] Create Process api query

查看:73
本文介绍了创建Process api查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我遇到了麻烦,我想在一个帖子中使用实时555库的代码但是根据链接中的文档< a href =http://www.live555.com/liveMedia/faq.html#threads> http://www.live555.com/liveMedia/faq.html#threads [ ^ ]

Hello All,

I am having a trouble that i want to use the code of live 555 libraries in a thread but according to there documentation from the link http://www.live555.com/liveMedia/faq.html#threads[^]

此代码是否线程安全?即,是否可以同时通过多个线程访问?



简答:否。如上所述,代码假设为单个执行的线程,使用事件循环而不是多个线程来实现并发。这通常使代码更容易调试,并且更容易跨多个操作系统移植,这些操作系统可能具有不同的线程API,或根本没有线程支持。 (有关这些相同方面的更强有力的论点,请参阅John Ousterhout的演讲。)

因此,尽管说代码不是线程安全,但它是真的也有点误导。这就像说高速铁路运输不适合适航。



更长的答案:多个线程仍然可以使用此代码,如果只有一个线程正确运行库代码,而其他线程只通过设置全局标志变量(例如事件循环''监视变量'')或通过调用''事件来与库通信触发'。 (注意triggerEvent()是唯一可以从外部(即非LIVE555)线程调用的LIVE555函数。)



另一种可能的方法从多个线程访问代码是让每个线程使用自己的UsageEnvironment和TaskScheduler对象,从而自己的事件循环。每个线程创建的对象(即,使用其自己的UsageEnvironment)不得交互(通过全局变量除外)。但是,不推荐这样的配置;相反,将这样的应用程序构造为多个进程而不是多个线程更安全。



无论如何,当使用LIVE555流媒体代码时,你应该熟悉事件驱动编程,并了解事件驱动的应用程序至少可以执行使用线程的应用程序(除非您实际上在多处理器上运行,在这种情况下,它通常更简单您的应用程序由多个进程(不仅仅是线程)组成 - 一个在每个处理器上运行。特别要注意,你不需要多个线程来同时传输(或接收)多个流。
Is this code ''thread safe''? I.e., can it be accessed by more than one thread at the same time?

Short answer: No. As noted above, the code assumes a single thread of execution, using an event loop - rather than multiple threads - for concurrency. This generally makes the code much easier to debug, and much easier to port across multiple operating systems, which may have different thread APIs, or no thread support at all. (For even stronger arguments along these same lines, see John Ousterhout''s presentation.)
Therefore, although it''s true to say that the code is not ''thread safe'', it''s also somewhat misleading. It''s like saying that a high-speed rail carriage is not ''airworthy''.

Longer answer: More than one thread can still use this code, if only one thread runs the library code proper, and the other thread(s) communicate with the library only by setting global ''flag'' variables (such as event loop ''watch variables''), or by calling ''event triggers''. (Note that "triggerEvent()" is the only LIVE555 function that may be called from an external (i.e., non-LIVE555) thread.)

Another possible way to access the code from multiple threads is to have each thread use its own "UsageEnvironment" and "TaskScheduler" objects, and thus its own event loop. The objects created by each thread (i.e., using its own "UsageEnvironment") must not interact (except via global variables). Such a configuration is not recommended, however; instead, it is safer to structure such an application as multiple processes, not multiple threads.

In any case, when using the "LIVE555 Streaming Media" code, you should be familiar with event-driven programming, and understand that an event-driven application can perform at least as well as one that uses threads (unless you''re actually running on a multiprocessor, in which case it''s usually simpler to have your application consist of multiple processes (not just threads) - one running on each processor). Note, in particular, that you do not need multiple threads in order to transmit (or receive) multiple streams concurrently.



他们说创建进程而不是创建线程现在问题是当我看到创建进程api它需要exe的路径,但我必须执行代码而不是运行exe,它怎么能完成。请指导


They say to create process rather than to create thread now the problem is when i saw the create process api it takes the path of the exe but i have to execute the code rather than to run the exe,how can it be done.Please guide

推荐答案

是的,我遇到了一个非常类似的问题。有一种方法,但它不是很干净。

而不是直接使用Live555使用内部包含Live555的FFMPEG。如果您遵循一个绝对严格的规则,则可以使用多个线程。

一次只允许一个线程运行创建或销毁视频流的设置或拆除代码。

一旦流启动并运行,您可以允许下一个线程创建另一个线程,但不能直到。

当您想要关闭时,一次只允许一个线程调用函数结束流或您的应用可能会在退出时锁定。

为此,您需要自己的 Mutex Critical Section 和一个只有几行的包装器,可通过它调用FFMPEG。我不能给你发一个或粘贴它,因为它不属于我,但我可以说它可以做到并且一旦你做对了就非常可靠。

最难的部分很可能是为了获得一个适当的最新Windows FFMPEG版本。
Yes I have come accross a very similar issue to this. There is a way but it''s not very clean.
Instead of using Live555 directly use FFMPEG which includes Live555 internally. You can then use multiple threading if you follow one absolutely strict rule.
Only allow one thread at a time to run the setup or teardown code that creates or destroys the video stream.
Once a stream is up and running you can allow the next thread to create another one but not until.
When you want to shut down only allow one thread at a time to call the functions to end a stream or your app may lock up on exit.
To do this you''re going to need your own Mutex or Critical Section and a wrapper of just a few lines through which to call FFMPEG. I can''t ship you one or paste it because it doesn''t belong to me but I can tell that it can be done and works very reliably once you get it right.
The hardest part may well be to get a proper up to date Windows build of FFMPEG itself.


这篇关于创建Process api查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆