Hi all! 2011/11/7 Martin Hamant <[email protected]>: > > > Le 05/11/2011 23:37, David Baelde a écrit : >> Hi Martin, >> >> I cannot propose any working solution, > > Hi David, > I thought so and I understand !! > >> but it should be possible to do >> it as follows: you setup an insert_metadata() operator, and use >> add_timeout() to periodically get the metadata from the URL, using >> http.get(), and insert that metadata (after having parsed it) using >> the function given by insert_metadata. >> >> Here's a standalone minimal example doing this. Unfortunately I cannot >> test at all at the moment. >> >> url = "http://localhost/metadata" >> source = blank() >> insert_source = insert_metadata(source) >> insert = fst(insert_source) >> source = snd(insert_source) >> delay = 5. >> def update_meta() = >> x_data = http.get(url) >> insert([("title",snd(x_data))]) >> end >> add_timeout(0., { update_meta() ; delay }) >> output.dummy(on_metadata(fun(m)->print(m),source)) > Yes, I already have an idea on how to implement each part but the > question remain on how to assemble it with dyn_sources and interface it > with my app. > > If you'd have like 5min of your time to devote, it would be for that > question: instead of storing only sources (in dyn_sources[]), how to > store a reference to a string that hold "url", for each stream link. > Then I'd only had to read/write what resides at this reference. > note: Last time we talk about that you talked about this, you talked > about "arbitrary tuples" , ie you can't do (x,y,z) but only (x,(y,z)) > > Inspired by the above, I thought about this: > dyn_sources := > list.append( [((uri,s0), stream_metaurl),((uri,output), > stream_metaurl)], > !dyn_sources ) > > But if I do this, then I have an error like: > At line 143, char 44-56: > this value has type > [((string*active_source(audio=2,video=0,midi=0))*_)] (infered at > line 7, char 19-20) > but it should be a subtype of > [(?A*_)] where ?A is an orderable type > > The code at line 143 is like follow: > result = list.fold(parse_list, ([], []), !dyn_sources)
Hmm.. Maybe this is related to: http://dev.sourcefabric.org/browse/LS-551 I am wondering something tough: could you benefit from another design of your solution? Sources IDs are unique and retrievable using source.id. Thus, why not using a separate list of source's metadata_url values, indexed by source ID? Something like: # The list sources_metadata_urls = ref [] # Update it def update_url(source, url) = id = source.id(s) elem = (id, url) # Directly append if not already present if not list.mem_assoc(id, !sources_metadata_urls) then sources_metadata_urls := list.append([elem], !sources_metadata_urls) else # This is more painful.. def f(x, cur) = test_id = fst(x) # Update if given element matches if test_id == id then list.append([elem], cur) else # Otherwise, put it back list.append([x], cur) end end sources_metadata_urls := list.fold(f, !sources_metadata_urls) end # Warning: no exception handling in liq for now: if (id, url) is not # in the list, we get "" (empty string) def get_url(source) = list.assoc(!sources_metadata_urls, source.id(source)) end I have not tested this, but I hope you get the idea.. Romain ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
